1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Full support of different display modes was added;

Infinite loop on removal of LOD structures was eliminated.
This commit is contained in:
vpa
2016-04-08 18:38:15 +03:00
parent 8bed5c1eb4
commit 43a665e7af
11 changed files with 99 additions and 5 deletions

View File

@@ -137,6 +137,12 @@ public:
//! iteration number
virtual void SetDetailLevelRange (const Standard_Integer theLODIdx, const Standard_Real theFrom, const Standard_Real theTo) = 0;
//! Returns range of LOD.
//! @param theLODIdx corresponds to the index of LOD in map of LOD manager. In case if no LOD was
//! removed, the LODs in map are located in order of addition and IDs are identical to the addition
//! iteration number
virtual void GetDetailLevelRange (const Standard_Integer theLODIdx, Standard_Real& theFrom, Standard_Real& theTo) const = 0;
public:
int Id;

View File

@@ -59,5 +59,6 @@ void Graphic3d_LOD::Clear (const Standard_Boolean theWithDestruction)
{
Handle(Graphic3d_Group) aGroup = myGroups.First();
aGroup->Remove();
myGroups.Remove (1);
}
}

View File

@@ -62,6 +62,16 @@ public:
return myFrom < theOther.myFrom;
}
const Standard_Real To() const
{
return myTo;
}
const Standard_Real From() const
{
return myFrom;
}
private:
Standard_Real myFrom;
Standard_Real myTo;

View File

@@ -97,6 +97,22 @@ void Graphic3d_LODManager::SetRange (Standard_Integer theLODIdx,
myIsToSortLODs = Standard_True;
}
//=======================================================================
// function : GetRange
// purpose :
//=======================================================================
void Graphic3d_LODManager::GetRange (const Standard_Integer theLODIdx,
Standard_Real& theFrom,
Standard_Real& theTo) const
{
if (theLODIdx < 1 || theLODIdx > myLODs.Extent())
return;
Graphic3d_RangeOfLOD aRange = myLODs.FindKey (theLODIdx)->GetRange();
theFrom = aRange.From();
theTo = aRange.To();
}
//=======================================================================
// function : GetCurrentGroups
// purpose :

View File

@@ -67,6 +67,12 @@ public:
const Standard_Real theFrom,
const Standard_Real theTo);
//! For ranged LODs, returns the distance interval where the LOD will be visible.
//! @param theLODIdx the index of LOD in sorted list
Standard_EXPORT void GetRange (const Standard_Integer theLODIdx,
Standard_Real& theFrom,
Standard_Real& theTo) const;
//! Returns own index of the LOD that is displayed
Standard_EXPORT Standard_Boolean HasLODToDisplay (const Handle(Graphic3d_Camera)& theCamera);

View File

@@ -1751,9 +1751,18 @@ Standard_Integer Graphic3d_Structure::NbDetailLevels() const
//function : SetDetailLevelRange
//purpose :
//=============================================================================
void Graphic3d_Structure::SetDetailLevelRange (const Standard_Integer theIdOfLOD, const Standard_Real theFrom, const Standard_Real theTo)
void Graphic3d_Structure::SetDetailLevelRange (const Standard_Integer theLODIdx, const Standard_Real theFrom, const Standard_Real theTo)
{
myCStructure->SetDetailLevelRange (theIdOfLOD, theFrom, theTo);
myCStructure->SetDetailLevelRange (theLODIdx, theFrom, theTo);
}
//=============================================================================
//function : GetDetailLevelRange
//purpose :
//=============================================================================
void Graphic3d_Structure::GetDetailLevelRange (const Standard_Integer theLODIdx, Standard_Real& theFrom, Standard_Real& theTo) const
{
myCStructure->GetDetailLevelRange (theLODIdx, theFrom, theTo);
}
//=============================================================================

View File

@@ -493,6 +493,12 @@ public:
//! iteration number
Standard_EXPORT void SetDetailLevelRange (const Standard_Integer theLODIdx, const Standard_Real theFrom, const Standard_Real theTo);
//! Returns range of LOD.
//! @param theLODIdx corresponds to the index of LOD in map of LOD manager. In case if no LOD was
//! removed, the LODs in map are located in order of addition and IDs are identical to the addition
//! iteration number
Standard_EXPORT void GetDetailLevelRange (const Standard_Integer theLODIdx, Standard_Real& theFrom, Standard_Real& theTo) const;
friend class Graphic3d_Group;

View File

@@ -163,10 +163,24 @@ void MeshVS_Mesh::ComputeLODs (const Handle(PrsMgr_PresentationManager3d)& thePr
continue;
aLODBldr->SetPresentationManager (thePrsMgr);
SetDataSource (aLODBldr->GetDataSource());
const TColStd_PackedMapOfInteger aTrgIdxs = aLODBldr->GetDataSource()->GetAllElements();
if (!aTrgIdxs.IsEmpty())
aLODBldr->Build (thePrs, aTrgIdxs, aDummy, Standard_True, theMode);
}
// Set up default ranges for LODs in shading or other display modes
if (theMode > 1)
{
const Handle(Prs3d_Presentation)& aWireframePrs = thePrsMgr->Presentation (this, 1)->Presentation();
for (Standard_Integer aLODIdx = 1; aLODIdx <= myBuilders.Length(); ++aLODIdx)
{
// Get range for wireframe mode
Standard_Real aFrom, aTo = std::numeric_limits<Standard_Real>::max();
aWireframePrs->GetDetailLevelRange (aLODIdx, aFrom, aTo);
thePrs->SetDetailLevelRange (aLODIdx, aFrom, aTo);
}
}
}
//================================================================

View File

@@ -809,6 +809,20 @@ void OpenGl_Structure::SetDetailLevelRange (const Standard_Integer theLODIdx,
myLODManager->SetRange (theLODIdx, theFrom, theTo);
}
//=======================================================================
//function : GetDetailLevelRange
//purpose :
//=======================================================================
void OpenGl_Structure::GetDetailLevelRange (const Standard_Integer theLODIdx,
Standard_Real& theFrom,
Standard_Real& theTo) const
{
if (myLODManager.IsNull() || theLODIdx < 1 || theLODIdx > myLODManager->NbOfDetailLevels())
return;
myLODManager->GetRange (theLODIdx, theFrom, theTo);
}
//=======================================================================
//function : DrawGroups
//purpose :

View File

@@ -106,10 +106,22 @@ public:
//! Remove group from this structure
Standard_EXPORT virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) Standard_OVERRIDE;
//! Sets range of LOD.
//! @param theLODIdx corresponds to the index of LOD in map of LOD manager. In case if no LOD was
//! removed, the LODs in map are located in order of addition and IDs are identical to the addition
//! iteration number
Standard_EXPORT virtual void SetDetailLevelRange (const Standard_Integer theLODIdx,
const Standard_Real theFrom,
const Standard_Real theTo) Standard_OVERRIDE;
//! Returns range of LOD.
//! @param theLODIdx corresponds to the index of LOD in map of LOD manager. In case if no LOD was
//! removed, the LODs in map are located in order of addition and IDs are identical to the addition
//! iteration number
Standard_EXPORT virtual void GetDetailLevelRange (const Standard_Integer theLODIdx,
Standard_Real& theFrom,
Standard_Real& theTo) const Standard_OVERRIDE;
public:
//! @return graphic groups

View File

@@ -1292,7 +1292,7 @@ static int MeshGenLODs (Draw_Interpretor& theDI,
aMeshParams.Deflection = aMaxDefl;
aMeshParams.Angle = 0.5;
aMeshParams.Relative = Standard_False;
aMeshParams.InParallel = Standard_False;
aMeshParams.InParallel = Standard_True;
aMeshParams.MinSize = Precision::Confusion();
aMeshParams.InternalVerticesMode = Standard_True;
aMeshParams.ControlSurfaceDeflection = Standard_True;
@@ -1318,7 +1318,7 @@ static int MeshGenLODs (Draw_Interpretor& theDI,
aParams.Deflection = aMaxDefl - aLODIdx * aDeflDecrFactor;
aParams.Angle = 0.5;
aParams.Relative = Standard_False;
aParams.InParallel = Standard_False;
aParams.InParallel = Standard_True;
aParams.MinSize = Precision::Confusion();
aParams.InternalVerticesMode = Standard_True;
aParams.ControlSurfaceDeflection = Standard_True;
@@ -1393,7 +1393,7 @@ static int MeshGenLODs (Draw_Interpretor& theDI,
}
}
if (!aMesh.IsNull() && aSavePath != "")
if (aSavePath != "")
{
if (aSavePath.Value (aSavePath.Length()) != '/')
{