diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder.cxx index e13b437d66..28adcb4bd0 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder.cxx @@ -586,11 +586,19 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, NCollection_List::Iterator itLFIm(*pLFIm); for (; itLFIm.More(); itLFIm.Next()) { - TopoDS_Face aFIm = TopoDS::Face(itLFIm.Value()); - if (BOPTools_AlgoTools::IsSplitToReverse(aFIm, aF, myContext)) + const TopoDS_Face& aFImRef = TopoDS::Face(itLFIm.Value()); + if (BOPTools_AlgoTools::IsSplitToReverse(aFImRef, aF, myContext)) + { + TopoDS_Face aFIm = aFImRef; aFIm.Reverse(); - aMapOri.Add(aFIm); - aMap.Add(aFIm); + aMapOri.Add(aFIm); + aMap.Add(aFIm); + } + else + { + aMapOri.Add(aFImRef); + aMap.Add(aFImRef); + } } } else @@ -647,7 +655,7 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, const int aNbF = aMap.Extent(); for (int j = 1; j <= aNbF; ++j) { - TopoDS_Shape aFIm = aMap(j); + const TopoDS_Shape& aFIm = aMap(j); bool isIN = anINMap.Contains(aFIm); bool isINOpposite = anOppositeINMap.Contains(aFIm); @@ -783,7 +791,7 @@ 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, TopoDS::Face(anExpF.Current())); + aBB.Add(aShell, anExpF.Current()); BOPTools_AlgoTools::OrientFacesOnShell(aShell); // Make solid out of the shell diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller.hxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller.hxx index d082da2148..6bdfb082a9 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller.hxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller.hxx @@ -46,6 +46,9 @@ #include #include #include + +#include + class IntTools_Context; class BOPDS_PaveBlock; class gp_Pnt; @@ -120,6 +123,9 @@ public: //! Sets the arguments for operation void SetArguments(const NCollection_List& theLS) { myArguments = theLS; } + //! Sets the arguments for operation (move semantics) + void SetArguments(NCollection_List&& theLS) { myArguments = std::move(theLS); } + //! Adds the argument for operation void AddArgument(const TopoDS_Shape& theShape) { myArguments.Append(theShape); } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 39e0cb1c36..c863b2e409 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -4066,7 +4066,8 @@ void BOPAlgo_PaveFiller::CorrectToleranceOfSE() // const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV)); double aTolV = BRep_Tool::Tolerance(aV); - double aMaxTol = aMVITol.IsBound(nV) ? aMVITol.Find(nV) : 0.; + const double* pMaxTol = aMVITol.Seek(nV); + double aMaxTol = pMaxTol ? *pMaxTol : 0.; // it makes no sense to compute the real tolerance if it is // impossible to reduce the tolerance at least 0.1% of the current value if (aTolV - aMaxTol < 0.001 * aTolV) diff --git a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_Set.cxx b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_Set.cxx index 02a68d8370..b980b3bb37 100644 --- a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_Set.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_Set.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,7 @@ static size_t NormalizedIds(const size_t aId, const int aDiv); BOPTools_Set::BOPTools_Set() : myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), - myShapes(myAllocator) + myShapes(256, myAllocator) { myNbShapes = 0; mySum = 0; @@ -37,7 +38,7 @@ BOPTools_Set::BOPTools_Set() BOPTools_Set::BOPTools_Set(const occ::handle& theAllocator) : myAllocator(theAllocator), - myShapes(myAllocator) + myShapes(256, myAllocator) { myNbShapes = 0; mySum = 0; @@ -48,16 +49,12 @@ BOPTools_Set::BOPTools_Set(const occ::handle& theAllo BOPTools_Set::BOPTools_Set(const BOPTools_Set& theOther) : myAllocator(theOther.myAllocator), + myShapes(theOther.myShapes), myShape(theOther.myShape), myNbShapes(theOther.myNbShapes), mySum(theOther.mySum), myUpper(theOther.myUpper) { - for (NCollection_List::Iterator aIt(theOther.myShapes); aIt.More(); aIt.Next()) - { - const TopoDS_Shape& aShape = aIt.Value(); - myShapes.Append(aShape); - } } //================================================================================================= @@ -87,21 +84,12 @@ int BOPTools_Set::NbShapes() const BOPTools_Set& BOPTools_Set::Assign(const BOPTools_Set& theOther) { - NCollection_List::Iterator aIt; - // myShape = theOther.myShape; myNbShapes = theOther.myNbShapes; mySum = theOther.mySum; myUpper = theOther.myUpper; myAllocator = theOther.myAllocator; - // - myShapes.Clear(); - aIt.Initialize(theOther.myShapes); - for (; aIt.More(); aIt.Next()) - { - const TopoDS_Shape& aSx = aIt.Value(); - myShapes.Append(aSx); - } + myShapes = theOther.myShapes; return *this; } @@ -116,36 +104,27 @@ const TopoDS_Shape& BOPTools_Set::Shape() const bool BOPTools_Set::IsEqual(const BOPTools_Set& theOther) const { - bool bRet; - // - bRet = false; - // if (theOther.myNbShapes != myNbShapes) { - return bRet; + return false; } // NCollection_Map aM1; - NCollection_List::Iterator aIt; // - aIt.Initialize(myShapes); - for (; aIt.More(); aIt.Next()) + for (int i = 0; i < myShapes.Size(); ++i) { - const TopoDS_Shape& aSx1 = aIt.Value(); - aM1.Add(aSx1); + aM1.Add(myShapes(i)); } // - aIt.Initialize(theOther.myShapes); - for (; aIt.More(); aIt.Next()) + for (int i = 0; i < theOther.myShapes.Size(); ++i) { - const TopoDS_Shape& aSx2 = aIt.Value(); - if (!aM1.Contains(aSx2)) + if (!aM1.Contains(theOther.myShapes(i))) { - return bRet; + return false; } } // - return !bRet; + return true; } //================================================================================================= @@ -167,7 +146,7 @@ void BOPTools_Set::Add(const TopoDS_Shape& theS, const TopAbs_ShapeEnum theType) const TopoDS_Shape& aSx = aExp.Current(); if (theType == TopAbs_EDGE) { - const TopoDS_Edge& aEx = *((TopoDS_Edge*)&aSx); + const TopoDS_Edge& aEx = TopoDS::Edge(aSx); if (BRep_Tool::Degenerated(aEx)) { continue; @@ -193,18 +172,15 @@ void BOPTools_Set::Add(const TopoDS_Shape& theS, const TopAbs_ShapeEnum theType) } } // - myNbShapes = myShapes.Extent(); + myNbShapes = myShapes.Size(); if (!myNbShapes) { return; } // - NCollection_List::Iterator aIt; - // - aIt.Initialize(myShapes); - for (; aIt.More(); aIt.Next()) + for (int i = 0; i < myShapes.Size(); ++i) { - const TopoDS_Shape& aSx = aIt.Value(); + const TopoDS_Shape& aSx = myShapes(i); aId = TopTools_ShapeMapHasher{}(aSx) % myUpper + 1; aIdN = NormalizedIds(aId, myNbShapes); mySum += aIdN; diff --git a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_Set.hxx b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_Set.hxx index 5b662ce2be..93537c39a5 100644 --- a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_Set.hxx +++ b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_Set.hxx @@ -22,7 +22,7 @@ #include #include #include -#include +#include class BOPTools_Set { @@ -57,7 +57,7 @@ protected: Standard_EXPORT void Clear(); occ::handle myAllocator; - NCollection_List myShapes; + NCollection_Vector myShapes; TopoDS_Shape myShape; int myNbShapes; size_t mySum; diff --git a/src/ModelingAlgorithms/TKMesh/IMeshData/IMeshData_Face.hxx b/src/ModelingAlgorithms/TKMesh/IMeshData/IMeshData_Face.hxx index c5a93826d4..e28dd27eff 100644 --- a/src/ModelingAlgorithms/TKMesh/IMeshData/IMeshData_Face.hxx +++ b/src/ModelingAlgorithms/TKMesh/IMeshData/IMeshData_Face.hxx @@ -66,8 +66,7 @@ protected: IMeshData_Face(const TopoDS_Face& theFace) : IMeshData_TessellatedShape(theFace) { - BRepAdaptor_Surface aSurfAdaptor(GetFace(), false); - mySurface = new BRepAdaptor_Surface(aSurfAdaptor); + mySurface = new BRepAdaptor_Surface(GetFace(), false); } private: diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter2d.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter2d.cxx index 0e45c7f490..ee32420245 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter2d.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter2d.cxx @@ -608,7 +608,6 @@ static void EdgeInter( // There can be doubles //---------------------------------- NCollection_List::Iterator it1LV1, it1LV2, it2LV1; - gp_Pnt P1, P2; bool Purge = true; while (Purge) @@ -618,21 +617,19 @@ static void EdgeInter( for (it1LV1.Initialize(LV1), it1LV2.Initialize(LV2); it1LV1.More(); it1LV1.Next(), it1LV2.Next()) { + const TopoDS_Vertex& aV1 = TopoDS::Vertex(it1LV1.Value()); + const gp_Pnt P1 = BRep_Tool::Pnt(aV1); + const double aTol1 = BRep_Tool::Tolerance(aV1); + j = 1; it2LV1.Initialize(LV1); while (j < i) { - P1 = BRep_Tool::Pnt(TopoDS::Vertex(it1LV1.Value())); - P2 = BRep_Tool::Pnt(TopoDS::Vertex(it2LV1.Value())); - // Modified by skv - Thu Jan 22 18:19:04 2004 OCC4455 Begin - // if (P1.IsEqual(P2,10*Tol)) { - double aTol; - - aTol = std::max(BRep_Tool::Tolerance(TopoDS::Vertex(it1LV1.Value())), - BRep_Tool::Tolerance(TopoDS::Vertex(it2LV1.Value()))); + const TopoDS_Vertex& aV2 = TopoDS::Vertex(it2LV1.Value()); + const gp_Pnt P2 = BRep_Tool::Pnt(aV2); + const double aTol = std::max(aTol1, BRep_Tool::Tolerance(aV2)); if (P1.IsEqual(P2, aTol)) { - // Modified by skv - Thu Jan 22 18:19:05 2004 OCC4455 End LV1.Remove(it1LV1); LV2.Remove(it1LV2); if (AffichPurge) @@ -1321,14 +1318,15 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const l -= 0.05 * (l - f); else { - f = FirstParOnPC; - l = LastParOnPC; + f = FirstParOnPC; + l = LastParOnPC; + const gp_Trsf aMinLocTrsf = MinLoc.Transformation(); GeomAPI_ProjectPointOnCurve Projector; if (!Precision::IsInfinite(FirstParOnPC)) { gp_Pnt2d P2d1 = MinPC->Value(FirstParOnPC); gp_Pnt P1 = MinSurf->Value(P2d1.X(), P2d1.Y()); - P1.Transform(MinLoc.Transformation()); + P1.Transform(aMinLocTrsf); Projector.Init(P1, C3d); if (Projector.NbPoints() > 0) f = Projector.LowerDistanceParameter(); @@ -1341,7 +1339,7 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const { gp_Pnt2d P2d2 = MinPC->Value(LastParOnPC); gp_Pnt P2 = MinSurf->Value(P2d2.X(), P2d2.Y()); - P2.Transform(MinLoc.Transformation()); + P2.Transform(aMinLocTrsf); Projector.Init(P2, C3d); if (Projector.NbPoints() > 0) l = Projector.LowerDistanceParameter(); diff --git a/src/Visualization/TKOpenGl/OpenGl/OpenGl_View.hxx b/src/Visualization/TKOpenGl/OpenGl/OpenGl_View.hxx index bd600191a2..36b4c5d87f 100644 --- a/src/Visualization/TKOpenGl/OpenGl/OpenGl_View.hxx +++ b/src/Visualization/TKOpenGl/OpenGl/OpenGl_View.hxx @@ -29,8 +29,8 @@ #include #include -#include -#include +#include +#include class OpenGl_BackgroundArray; class OpenGl_DepthPeeling; @@ -1063,13 +1063,13 @@ protected: //! @name fields related to ray-tracing int myUniformLocations[2][OpenGl_RT_NbVariables]; //! State of OpenGL structures reflected to ray-tracing. - std::map myStructureStates; + NCollection_DataMap myStructureStates; //! PrimitiveArray to TriangleSet map for scene partial update. - std::map myArrayToTrianglesMap; + NCollection_DataMap myArrayToTrianglesMap; //! Set of IDs of non-raytracable elements (to detect updates). - std::set myNonRaytraceStructureIDs; + NCollection_Map myNonRaytraceStructureIDs; //! Marks if environment map should be updated. bool myToUpdateEnvironmentMap; diff --git a/src/Visualization/TKOpenGl/OpenGl/OpenGl_View_Raytrace.cxx b/src/Visualization/TKOpenGl/OpenGl/OpenGl_View_Raytrace.cxx index 3323007010..a8c3f46c7a 100644 --- a/src/Visualization/TKOpenGl/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/Visualization/TKOpenGl/OpenGl/OpenGl_View_Raytrace.cxx @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "../../TKService/Shaders/Shaders_RaytraceBase_vs.pxx" #include "../../TKService/Shaders/Shaders_RaytraceBase_fs.pxx" @@ -87,7 +89,7 @@ bool OpenGl_View::updateRaytraceGeometry(const RaytraceUpdateMode theM { myRaytraceGeometry.ClearMaterials(); - myArrayToTrianglesMap.clear(); + myArrayToTrianglesMap.Clear(); myIsRaytraceDataValid = false; } @@ -95,15 +97,15 @@ bool OpenGl_View::updateRaytraceGeometry(const RaytraceUpdateMode theM // The set of processed structures (reflected to ray-tracing) // This set is used to remove out-of-date records from the // hash map of structures - std::set anElements; + NCollection_Map anElements; // Set to store all currently visible OpenGL primitive arrays // applicable for ray-tracing - std::set anArrayIDs; + NCollection_Map anArrayIDs; // Set to store all non-raytracable elements allowing tracking // of changes in OpenGL scene (only for path tracing) - std::set aNonRaytraceIDs; + NCollection_Map aNonRaytraceIDs; for (NCollection_List>::Iterator aLayerIter(myZLayers.Layers()); aLayerIter.More(); @@ -135,8 +137,8 @@ bool OpenGl_View::updateRaytraceGeometry(const RaytraceUpdateMode theM } else if (aStructure->IsVisible() && myRaytraceParameters.GlobalIllumination) { - aNonRaytraceIDs.insert(aStructure->highlight ? aStructure->Identification() - : -aStructure->Identification()); + aNonRaytraceIDs.Add(aStructure->highlight ? aStructure->Identification() + : -aStructure->Identification()); } } else if (theMode == OpenGl_GUM_PREPARE) @@ -163,7 +165,7 @@ bool OpenGl_View::updateRaytraceGeometry(const RaytraceUpdateMode theM if (aPrimArray != nullptr) { - anArrayIDs.insert(aPrimArray->GetUID()); + anArrayIDs.Add(aPrimArray->GetUID()); } } } @@ -176,7 +178,7 @@ bool OpenGl_View::updateRaytraceGeometry(const RaytraceUpdateMode theM } else if (addRaytraceStructure(aStructure, theGlContext)) { - anElements.insert(aStructure); // structure was processed + anElements.Add(aStructure); // structure was processed } } } @@ -199,11 +201,11 @@ bool OpenGl_View::updateRaytraceGeometry(const RaytraceUpdateMode theM continue; } - if (anArrayIDs.find(aTriangleSet->AssociatedPArrayID()) != anArrayIDs.end()) + if (anArrayIDs.Contains(aTriangleSet->AssociatedPArrayID())) { anUnchangedObjects.Append(myRaytraceGeometry.Objects().Value(anObjIdx)); - myArrayToTrianglesMap[aTriangleSet->AssociatedPArrayID()] = aTriangleSet; + myArrayToTrianglesMap.Bind(aTriangleSet->AssociatedPArrayID(), aTriangleSet); } } @@ -214,19 +216,24 @@ bool OpenGl_View::updateRaytraceGeometry(const RaytraceUpdateMode theM else if (theMode == OpenGl_GUM_REBUILD) { // Actualize the hash map of structures - remove out-of-date records - std::map::iterator anIter = myStructureStates.begin(); - - while (anIter != myStructureStates.end()) + NCollection_Vector aKeysToRemove( + myStructureStates.Extent() > 0 ? myStructureStates.Extent() : 1); + for (NCollection_DataMap::Iterator anIter( + myStructureStates); + anIter.More(); + anIter.Next()) { - if (anElements.find(anIter->first) == anElements.end()) + if (!anElements.Contains(anIter.Key())) { - myStructureStates.erase(anIter++); - } - else - { - ++anIter; + aKeysToRemove.Append(anIter.Key()); } } + for (NCollection_Vector::Iterator aKeyIter(aKeysToRemove); + aKeyIter.More(); + aKeyIter.Next()) + { + myStructureStates.UnBind(aKeyIter.Value()); + } // Actualize OpenGL layer list state myRaytraceLayerListState = myZLayers.ModificationStateOfRaytracable(); @@ -247,24 +254,12 @@ bool OpenGl_View::updateRaytraceGeometry(const RaytraceUpdateMode theM if (myRaytraceParameters.GlobalIllumination) { - bool toRestart = aNonRaytraceIDs.size() != myNonRaytraceStructureIDs.size(); - - for (std::set::iterator anID = aNonRaytraceIDs.begin(); - anID != aNonRaytraceIDs.end() && !toRestart; - ++anID) - { - if (myNonRaytraceStructureIDs.find(*anID) == myNonRaytraceStructureIDs.end()) - { - toRestart = true; - } - } - - if (toRestart) + if (!NCollection_MapAlgo::IsEqual(myNonRaytraceStructureIDs, aNonRaytraceIDs)) { myAccumFrames = 0; } - myNonRaytraceStructureIDs = aNonRaytraceIDs; + myNonRaytraceStructureIDs.Exchange(aNonRaytraceIDs); } return true; @@ -288,18 +283,15 @@ bool OpenGl_View::toUpdateStructure(const OpenGl_Structure* theStructure) return false; // did not contain ray-trace elements } - std::map::iterator aStructState = - myStructureStates.find(theStructure); + const StructState* aStructState = myStructureStates.Seek(theStructure); - if (aStructState == myStructureStates.end() - || aStructState->second.StructureState != theStructure->ModificationState()) + if (aStructState == nullptr || aStructState->StructureState != theStructure->ModificationState()) { return true; } else if (theStructure->InstancedStructure() != nullptr) { - return aStructState->second.InstancedState - != theStructure->InstancedStructure()->ModificationState(); + return aStructState->InstancedState != theStructure->InstancedStructure()->ModificationState(); } return false; @@ -319,33 +311,21 @@ void buildTextureTransform(const occ::handle& theParams } // Apply scaling - const NCollection_Vec2& aScale = theParams->Scale(); + const float aScaleX = theParams->Scale().x(); + const float aScaleY = theParams->Scale().y(); - theMatrix.ChangeValue(0, 0) *= aScale.x(); - theMatrix.ChangeValue(1, 0) *= aScale.x(); - theMatrix.ChangeValue(2, 0) *= aScale.x(); - theMatrix.ChangeValue(3, 0) *= aScale.x(); - - theMatrix.ChangeValue(0, 1) *= aScale.y(); - theMatrix.ChangeValue(1, 1) *= aScale.y(); - theMatrix.ChangeValue(2, 1) *= aScale.y(); - theMatrix.ChangeValue(3, 1) *= aScale.y(); + theMatrix.ChangeValue(0, 0) = aScaleX; + theMatrix.ChangeValue(1, 1) = aScaleY; // Apply translation const NCollection_Vec2 aTrans = -theParams->Translation(); - - theMatrix.ChangeValue(0, 3) = - theMatrix.GetValue(0, 0) * aTrans.x() + theMatrix.GetValue(0, 1) * aTrans.y(); - - theMatrix.ChangeValue(1, 3) = - theMatrix.GetValue(1, 0) * aTrans.x() + theMatrix.GetValue(1, 1) * aTrans.y(); - - theMatrix.ChangeValue(2, 3) = - theMatrix.GetValue(2, 0) * aTrans.x() + theMatrix.GetValue(2, 1) * aTrans.y(); + theMatrix.ChangeValue(0, 3) = aScaleX * aTrans.x(); + theMatrix.ChangeValue(1, 3) = aScaleY * aTrans.y(); // Apply rotation - const float aSin = std::sin(-theParams->Rotation() * static_cast(M_PI / 180.0)); - const float aCos = std::cos(-theParams->Rotation() * static_cast(M_PI / 180.0)); + const float aAngle = -theParams->Rotation() * static_cast(M_PI / 180.0); + const float aSin = std::sin(aAngle); + const float aCos = std::cos(aAngle); BVH_Mat4f aRotationMat; aRotationMat.SetValue(0, 0, aCos); @@ -492,7 +472,7 @@ bool OpenGl_View::addRaytraceStructure(const OpenGl_Structure* theStr { if (!theStructure->IsVisible()) { - myStructureStates[theStructure] = StructState(theStructure); + myStructureStates.Bind(theStructure, StructState(theStructure)); return true; } @@ -513,7 +493,7 @@ bool OpenGl_View::addRaytraceStructure(const OpenGl_Structure* theStr theGlContext); } - myStructureStates[theStructure] = StructState(theStructure); + myStructureStates.Bind(theStructure, StructState(theStructure)); return aResult; } @@ -528,6 +508,11 @@ bool OpenGl_View::addRaytraceGroups(const OpenGl_Structure* theStruct const occ::handle& theGlContext) { NCollection_Mat4 aMat4; + const bool hasTrsf = !theTrsf.IsNull(); + if (hasTrsf) + { + theTrsf->Trsf().GetMat4(aMat4); + } for (OpenGl_Structure::GroupIterator aGroupIter(theStructure->Groups()); aGroupIter.More(); aGroupIter.Next()) { @@ -564,16 +549,14 @@ bool OpenGl_View::addRaytraceGroups(const OpenGl_Structure* theStruct if (aPrimArray != nullptr) { - std::map::iterator aSetIter = - myArrayToTrianglesMap.find(aPrimArray->GetUID()); + OpenGl_TriangleSet** aSetPtr = myArrayToTrianglesMap.ChangeSeek(aPrimArray->GetUID()); - if (aSetIter != myArrayToTrianglesMap.end()) + if (aSetPtr != nullptr) { - OpenGl_TriangleSet* aSet = aSetIter->second; + OpenGl_TriangleSet* aSet = *aSetPtr; opencascade::handle> aTransform = new BVH_Transform(); - if (!theTrsf.IsNull()) + if (hasTrsf) { - theTrsf->Trsf().GetMat4(aMat4); aTransform->SetTransform(aMat4); } @@ -591,9 +574,8 @@ bool OpenGl_View::addRaytraceGroups(const OpenGl_Structure* theStruct { opencascade::handle> aTransform = new BVH_Transform(); - if (!theTrsf.IsNull()) + if (hasTrsf) { - theTrsf->Trsf().GetMat4(aMat4); aTransform->SetTransform(aMat4); } @@ -1158,54 +1140,54 @@ bool OpenGl_View::ShaderSource::LoadFromStrings(const TCollection_AsciiString* t TCollection_AsciiString OpenGl_View::generateShaderPrefix( const occ::handle& theGlContext) const { - TCollection_AsciiString aPrefixString = TCollection_AsciiString("#define STACK_SIZE ") - + TCollection_AsciiString(myRaytraceParameters.StackSize) - + "\n" + TCollection_AsciiString("#define NB_BOUNCES ") - + TCollection_AsciiString(myRaytraceParameters.NbBounces); + TCollection_AsciiString aPrefixString("#define STACK_SIZE "); + aPrefixString += TCollection_AsciiString(myRaytraceParameters.StackSize); + aPrefixString += "\n#define NB_BOUNCES "; + aPrefixString += TCollection_AsciiString(myRaytraceParameters.NbBounces); if (myRaytraceParameters.IsZeroToOneDepth) { - aPrefixString += TCollection_AsciiString("\n#define THE_ZERO_TO_ONE_DEPTH"); + aPrefixString += "\n#define THE_ZERO_TO_ONE_DEPTH"; } if (myRaytraceParameters.TransparentShadows) { - aPrefixString += TCollection_AsciiString("\n#define TRANSPARENT_SHADOWS"); + aPrefixString += "\n#define TRANSPARENT_SHADOWS"; } if (!theGlContext->ToRenderSRGB()) { - aPrefixString += TCollection_AsciiString("\n#define THE_SHIFT_sRGB"); + aPrefixString += "\n#define THE_SHIFT_sRGB"; } // If OpenGL driver supports bindless textures and texturing // is actually used, activate texturing in ray-tracing mode if (myRaytraceParameters.UseBindlessTextures && theGlContext->arbTexBindless != nullptr) { - aPrefixString += TCollection_AsciiString("\n#define USE_TEXTURES") - + TCollection_AsciiString("\n#define MAX_TEX_NUMBER ") - + TCollection_AsciiString(OpenGl_RaytraceGeometry::MAX_TEX_NUMBER); + aPrefixString += "\n#define USE_TEXTURES"; + aPrefixString += "\n#define MAX_TEX_NUMBER "; + aPrefixString += TCollection_AsciiString(OpenGl_RaytraceGeometry::MAX_TEX_NUMBER); } if (myRaytraceParameters.GlobalIllumination) // path tracing activated { - aPrefixString += TCollection_AsciiString("\n#define PATH_TRACING"); + aPrefixString += "\n#define PATH_TRACING"; if (myRaytraceParameters.AdaptiveScreenSampling) // adaptive screen sampling requested { if (theGlContext->IsGlGreaterEqual(4, 4)) { - aPrefixString += TCollection_AsciiString("\n#define ADAPTIVE_SAMPLING"); + aPrefixString += "\n#define ADAPTIVE_SAMPLING"; if (myRaytraceParameters.AdaptiveScreenSamplingAtomic && theGlContext->CheckExtension("GL_NV_shader_atomic_float")) { - aPrefixString += TCollection_AsciiString("\n#define ADAPTIVE_SAMPLING_ATOMIC"); + aPrefixString += "\n#define ADAPTIVE_SAMPLING_ATOMIC"; } } } if (myRaytraceParameters.TwoSidedBsdfModels) // two-sided BSDFs requested { - aPrefixString += TCollection_AsciiString("\n#define TWO_SIDED_BXDF"); + aPrefixString += "\n#define TWO_SIDED_BXDF"; } switch (myRaytraceParameters.ToneMappingMethod) @@ -1213,24 +1195,24 @@ TCollection_AsciiString OpenGl_View::generateShaderPrefix( case Graphic3d_ToneMappingMethod_Disabled: break; case Graphic3d_ToneMappingMethod_Filmic: - aPrefixString += TCollection_AsciiString("\n#define TONE_MAPPING_FILMIC"); + aPrefixString += "\n#define TONE_MAPPING_FILMIC"; break; } } if (myRaytraceParameters.ToIgnoreNormalMap) { - aPrefixString += TCollection_AsciiString("\n#define IGNORE_NORMAL_MAP"); + aPrefixString += "\n#define IGNORE_NORMAL_MAP"; } if (myRaytraceParameters.CubemapForBack) { - aPrefixString += TCollection_AsciiString("\n#define BACKGROUND_CUBEMAP"); + aPrefixString += "\n#define BACKGROUND_CUBEMAP"; } if (myRaytraceParameters.DepthOfField) { - aPrefixString += TCollection_AsciiString("\n#define DEPTH_OF_FIELD"); + aPrefixString += "\n#define DEPTH_OF_FIELD"; } return aPrefixString;