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

Remarks from KGV

This commit is contained in:
vpa
2015-11-23 18:55:03 +03:00
parent a370cc6537
commit 3b8f64569e
13 changed files with 34 additions and 57 deletions

View File

@@ -114,12 +114,12 @@ public:
virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) = 0;
//! Create new LOD within this structure
virtual Handle(Graphic3d_LOD) NewLOD (const Handle(Graphic3d_Structure)& theStruct) = 0;
virtual Handle(Graphic3d_LOD) NewLOD() = 0;
//! Remove group from this structure
virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) = 0;
virtual Standard_Integer GetDetailLevelsNb() const = 0;
virtual Standard_Integer NbDetailLevels() const = 0;
virtual void SetDetailLevelRange (const Standard_Integer theIdOfLOD, const Standard_Real theFrom, const Standard_Real theTo) = 0;

View File

@@ -22,16 +22,6 @@
Graphic3d_LOD::~Graphic3d_LOD()
{
myGroups.Clear();
myParent.Nullify();
}
//=======================================================================
// function : SetParent
// purpose :
//=======================================================================
void Graphic3d_LOD::SetParent (const Handle(Graphic3d_Structure)& theParent)
{
myParent = theParent;
}
//=======================================================================
@@ -47,7 +37,7 @@ void Graphic3d_LOD::SetRange (const Standard_Real /*theFrom*/, const Standard_Re
// function : NewGroup
// purpose :
//=======================================================================
Handle(Graphic3d_Group) Graphic3d_LOD::NewGroup()
Handle(Graphic3d_Group) Graphic3d_LOD::NewGroup (const Handle(Graphic3d_Structure)& /*theParentStruct*/)
{
return NULL;
}
@@ -56,12 +46,13 @@ Handle(Graphic3d_Group) Graphic3d_LOD::NewGroup()
// function : ComputeMetrics
// purpose :
//=======================================================================
Standard_Real Graphic3d_LOD::ComputeMetrics (const Handle(Graphic3d_Camera)& theCamera) const
Standard_Real Graphic3d_LOD::ComputeMetrics (const Handle(Graphic3d_Camera)& theCamera,
const Handle(Graphic3d_CStructure)& theParentStruct) const
{
if (myParent.IsNull())
if (theParentStruct.IsNull())
return std::numeric_limits<Standard_Real>::max();
Graphic3d_BndBox4f aBndBox = myParent->CStructure()->BoundingBox();
Graphic3d_BndBox4f aBndBox = theParentStruct->BoundingBox();
const Graphic3d_Vec4 aCenter = aBndBox.Center();
const gp_Pnt aGpCenter = gp_Pnt (aCenter.x(), aCenter.y(), aCenter.z());
return (theCamera->Eye().Distance (aGpCenter)) / theCamera->Scale();

View File

@@ -30,16 +30,15 @@ public:
Standard_EXPORT virtual ~Graphic3d_LOD();
Standard_EXPORT virtual void SetRange (const Standard_Real theFrom, const Standard_Real theTo);
Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup();
Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theParentStruct);
Standard_EXPORT Standard_Real ComputeMetrics (const Handle(Graphic3d_Camera)& theCamera) const;
Standard_EXPORT void SetParent (const Handle(Graphic3d_Structure)& theParent);
Standard_EXPORT Standard_Real ComputeMetrics (const Handle(Graphic3d_Camera)& theCamera,
const Handle(Graphic3d_CStructure)& theParentStruct) const;
DEFINE_STANDARD_RTTI (Graphic3d_LOD, Standard_Transient)
protected:
Graphic3d_SequenceOfGroup myGroups;
Handle(Graphic3d_Structure) myParent;
Graphic3d_SequenceOfGroup myGroups;
};
DEFINE_STANDARD_HANDLE (Graphic3d_LOD, Standard_Transient)

View File

@@ -1749,16 +1749,16 @@ Handle(Graphic3d_Group) Graphic3d_Structure::NewGroup()
//=============================================================================
Handle(Graphic3d_LOD) Graphic3d_Structure::NewLOD()
{
return myCStructure->NewLOD (this);
return myCStructure->NewLOD();
}
//=============================================================================
//function : GetDetailLevelsNb
//function : NbDetailLevels
//purpose :
//=============================================================================
Standard_Integer Graphic3d_Structure::GetDetailLevelsNb() const
Standard_Integer Graphic3d_Structure::NbDetailLevels() const
{
return myCStructure->GetDetailLevelsNb();
return myCStructure->NbDetailLevels();
}
//=============================================================================

View File

@@ -497,7 +497,7 @@ public:
//! Returns the low-level structure
const Handle(Graphic3d_CStructure)& CStructure() const;
Standard_EXPORT Standard_Integer GetDetailLevelsNb() const;
Standard_EXPORT Standard_Integer NbDetailLevels() const;
Standard_EXPORT void SetDetailLevelRange (const Standard_Integer theIdOfLOD, const Standard_Real theFrom, const Standard_Real theTo);

View File

@@ -186,7 +186,7 @@ void MeshVS_LODDataSource::ComputePrs (const Handle(AIS_InteractiveObject) theMe
if (aMesh.IsNull())
return;
Standard_Boolean hasNodes = !myNodeIdxs.IsEmpty();
// Standard_Boolean hasNodes = !myNodeIdxs.IsEmpty();
Standard_Boolean hasTrgs = !myTriangleIdxs.IsEmpty();
Handle(Prs3d_Presentation) aMainPrs = theMesh->Presentation();
const Standard_Integer aDispMode = theMesh->DisplayMode();
@@ -591,12 +591,12 @@ void MeshVS_LODDataSource::drawArrays (const Handle(Prs3d_Presentation)& theBase
Aspect_TypeOfLine aType;
Standard_Real aWidth;
Handle(Graphic3d_LOD) aNewLod = Prs3d_Root::NewLOD (theBasePrs);
Handle(Graphic3d_LOD) aNewLod = theBasePrs->NewLOD();
theFillAsp->Values (aStyle, anIntColor, aBackColor, anEdgeColor, aType, aWidth);
if (isPolygons && theFillAsp->FrontMaterial().Transparency() < 0.01)
{
Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup();
Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup (theBasePrs);
theFillAsp->SetEdgeOff();
@@ -626,7 +626,7 @@ void MeshVS_LODDataSource::drawArrays (const Handle(Prs3d_Presentation)& theBase
if (isPolylines && !theIsPolygonsEdgesOff)
{
Handle (Graphic3d_Group) aLGroup = aNewLod->NewGroup();
Handle (Graphic3d_Group) aLGroup = aNewLod->NewGroup (theBasePrs);
theFillAsp->SetEdgeOff();
if (theIsSelected)
@@ -642,7 +642,7 @@ void MeshVS_LODDataSource::drawArrays (const Handle(Prs3d_Presentation)& theBase
if (isLinkPolylines)
{
Handle (Graphic3d_Group) aBeamGroup = aNewLod->NewGroup();
Handle (Graphic3d_Group) aBeamGroup = aNewLod->NewGroup (theBasePrs);
theFillAsp->SetEdgeOff();
if (!theIsSelected)
@@ -654,7 +654,7 @@ void MeshVS_LODDataSource::drawArrays (const Handle(Prs3d_Presentation)& theBase
if (isPolygons && theFillAsp->FrontMaterial().Transparency() >= 0.01)
{
Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup();
Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup (theBasePrs);
theFillAsp->SetEdgeOff();

View File

@@ -39,9 +39,9 @@ void OpenGl_LOD::SetRange (const Standard_Real theFrom, const Standard_Real theT
// function : NewGroup
// purpose :
//=======================================================================
Handle(Graphic3d_Group) OpenGl_LOD::NewGroup()
Handle(Graphic3d_Group) OpenGl_LOD::NewGroup (const Handle(Graphic3d_Structure)& theParentStruct)
{
Handle(OpenGl_Group) aGroup = new OpenGl_Group (myParent);
Handle(OpenGl_Group) aGroup = new OpenGl_Group (theParentStruct);
myGroups.Append (aGroup);
return aGroup;
}

View File

@@ -25,12 +25,11 @@ struct OpenGl_RangeOfLOD
{
public:
OpenGl_RangeOfLOD (const Standard_Real theFrom, const Standard_Real theTo)
: myTo (theTo),
myFrom (theFrom)
{
Standard_ASSERT_RAISE (theFrom < theTo,
"The upper boundary of the interval must be greater than lower one!");
myTo = theTo;
myFrom = theFrom;
}
Standard_Boolean IsIn (const Standard_Real theVal) const
@@ -72,7 +71,7 @@ public:
return myRange;
}
Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup() Standard_OVERRIDE;
Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theParentStruct) Standard_OVERRIDE;
const Graphic3d_SequenceOfGroup& DrawGroups() const
{
@@ -82,7 +81,7 @@ public:
DEFINE_STANDARD_RTTI (OpenGl_LOD, Graphic3d_LOD)
private:
OpenGl_RangeOfLOD myRange;
OpenGl_RangeOfLOD myRange;
};
DEFINE_STANDARD_HANDLE (OpenGl_LOD, Graphic3d_LOD)

View File

@@ -437,10 +437,9 @@ Handle(Graphic3d_Group) OpenGl_Structure::NewGroup (const Handle(Graphic3d_Struc
// function : NewLOD
// purpose :
// =======================================================================
Handle(Graphic3d_LOD) OpenGl_Structure::NewLOD (const Handle(Graphic3d_Structure)& theStruct)
Handle(Graphic3d_LOD) OpenGl_Structure::NewLOD()
{
Handle(OpenGl_LOD) aLOD = new OpenGl_LOD();
aLOD->SetParent (theStruct);
myLODVec.Append (aLOD);
return aLOD;
}
@@ -539,7 +538,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
return;
}
Handle(OpenGl_LOD) aLODToRender = NULL;
Handle(OpenGl_LOD) aLODToRender;
if (myLODVec.Size() > 0)
{
findCurrentLOD (theWorkspace);
@@ -818,7 +817,7 @@ Standard_Integer OpenGl_Structure::binSearchLOD (const Standard_Integer theFirst
//=======================================================================
void OpenGl_Structure::findCurrentLOD (const Handle(OpenGl_Workspace)& theWorkspace) const
{
Standard_Real aMetric = myLODVec.Value (0)->ComputeMetrics (theWorkspace->View()->Camera());
Standard_Real aMetric = myLODVec.Value (0)->ComputeMetrics (theWorkspace->View()->Camera(), this);
std::cout << aMetric << std::endl;
if (myCurrentLodId != -1 && myLODVec.Value (myCurrentLodId)->GetRange().IsIn (aMetric))
return;

View File

@@ -101,7 +101,7 @@ public:
Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct);
//! Create new LOD within this structure
Standard_EXPORT virtual Handle(Graphic3d_LOD) NewLOD (const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE;
Standard_EXPORT virtual Handle(Graphic3d_LOD) NewLOD() Standard_OVERRIDE;
//! Remove group from this structure
Standard_EXPORT virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup);
@@ -201,7 +201,7 @@ public:
//! Is the structure ray-tracable (contains ray-tracable elements)?
Standard_Boolean IsRaytracable() const;
Standard_EXPORT virtual Standard_Integer GetDetailLevelsNb() const Standard_OVERRIDE
Standard_EXPORT virtual Standard_Integer NbDetailLevels() const Standard_OVERRIDE
{
return (Standard_Integer)myLODVec.Size();
}

View File

@@ -25,12 +25,3 @@ Handle (Graphic3d_Group) Prs3d_Root::NewGroup (const Handle (Prs3d_Presentation)
{
return Prs3d->NewGroup();
}
//=======================================================================
//function : CreateLOD
//purpose :
//=======================================================================
Handle(Graphic3d_LOD) Prs3d_Root::NewLOD (const Handle (Prs3d_Presentation)& theParentPrs)
{
return theParentPrs->NewLOD();
}

View File

@@ -45,8 +45,6 @@ public:
//! objects in the display.
//! A group also contains the attributes whose ranges are limited to the primitives in it.
Standard_EXPORT static Handle(Graphic3d_Group) NewGroup (const Handle(Prs3d_Presentation)& Prs3d);
Standard_EXPORT static Handle(Graphic3d_LOD) NewLOD (const Handle (Prs3d_Presentation)& theParentPrs);
};

View File

@@ -1488,7 +1488,7 @@ static int MeshLod (Draw_Interpretor& theDI,
Handle(MeshVS_LODDataSource) aLod = new MeshVS_LODDataSource (aSTLMesh);
aLod->ComputePrs (aMesh);
Standard_Integer aIdOfLod = aMesh->Presentation()->GetDetailLevelsNb();
Standard_Integer aIdOfLod = aMesh->Presentation()->NbDetailLevels();
aMesh->Presentation()->SetDetailLevelRange (aIdOfLod - 1, aFromRange, aToRange);
return 0;