Bounding box of LOD Graphic3d_Structure is computed as combined box for all LOD graphic groups;
Method HasLevelsOfDetail() was added to presentable objects to mark objects presented via LODs at the time of Compute() call;
Redefineable method ComputeLods() was added to presentable object for customization.
//! Get z layer ID
Graphic3d_ZLayerId ZLayer() const { return myZLayer; }
+ const Handle(Graphic3d_LODManager)& GetLodManager() const
+ {
+ return myLODManager;
+ }
+
public:
//! Update structure visibility state
{
return myLODs.Value (myCurrentLODIdx)->GetDrawGroups();
}
+
+ //=======================================================================
+// function : GetCombinedBndBox
+// purpose :
+//=======================================================================
+ void Graphic3d_LODManager::GetCombinedBndBox (Graphic3d_BndBox4f& theBndBox) const
+ {
+ for (Standard_Integer aLodIdx = 0; aLodIdx < myLODs.Size(); ++aLodIdx)
+ {
+ const Graphic3d_SequenceOfGroup& aGroups = myLODs.Value (aLodIdx)->GetDrawGroups();
+ for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
+ {
+ theBndBox.Combine (aGroupIter.Value()->BoundingBox());
+ }
+ }
+ }
Standard_EXPORT virtual Handle(Graphic3d_LOD) AddNewLOD() = 0;
+ Standard_EXPORT void GetCombinedBndBox (Graphic3d_BndBox4f& theBndBox) const;
+
DEFINE_STANDARD_RTTIEXT (Graphic3d_LODManager, Standard_Transient)
protected:
#include <Graphic3d_DataStructureManager.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_Group.hxx>
+#include <Graphic3d_LODManager.hxx>
#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
#include <Graphic3d_MapOfStructure.hxx>
#include <Graphic3d_MaterialAspect.hxx>
Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
{
Graphic3d_BndBox4f aBnd;
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
+ const Handle(Graphic3d_LODManager)& aLodMgr = myCStructure->GetLodManager();
+ if (aLodMgr.IsNull())
+ {
+ for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
+ {
+ aBnd.Combine (aGroupIter.Value()->BoundingBox());
+ }
+ }
+ else
{
- aBnd.Combine (aGroupIter.Value()->BoundingBox());
+ aLodMgr->GetCombinedBndBox (aBnd);
}
return aBnd;
}
if (myParentMesh == NULL)
return;
- //if (!theIsElement)
- //{
- // Standard_Boolean hasSelectFlag = ((aDispMode & MeshVS_DMF_SelectionPrs) != 0);
- // Standard_Boolean hasHilightFlag = ((aDispMode & MeshVS_DMF_HilightPrs) != 0);
-
- // Standard_Real aCoordsBuf[3];
- // TColStd_Array1OfReal aCoords (*aCoordsBuf, 1, 3);
- // Standard_Integer aNodesNb;
- // MeshVS_EntityType aType;
-
- // TColStd_PackedMapOfInteger anIDs;
- // anIDs.Assign (myNodeIdxs);
- // if (!hasSelectFlag && !hasHilightFlag)
- // {
- // // subtract the hidden nodes and ids to exclude (to minimize allocated memory)
- // Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = aMesh->GetHiddenNodes();
- // if (!aHiddenNodes.IsNull())
- // anIDs.Subtract (aHiddenNodes->Map());
- // }
-
- // Standard_Integer aSize = anIDs.Extent();
- // if (aSize > 0)
- // {
- // Handle(Graphic3d_ArrayOfPoints) aNodePoints = new Graphic3d_ArrayOfPoints (aSize);
- // Standard_Integer aPntsNb = 0;
- // for (TColStd_MapIteratorOfPackedMapOfInteger aNodeIdxsIter (myNodeIdxs); aNodeIdxsIter.More(); aNodeIdxsIter.Next())
- // {
- // const Standard_Integer aKey = aNodeIdxsIter.Key();
- // if (GetGeom (aKey, Standard_False, aCoords, aNodesNb, aType))
- // {
- // aPntsNb++;
- // aNodePoints->AddVertex (aCoords(1), aCoords(2), aCoords(3));
- // }
- // }
-
- // if (aPntsNb > 0)
- // {
- // Handle(Graphic3d_LOD) aNewLod = Prs3d_Root::NewLOD (aMainPrs);
- // Handle(Graphic3d_Group) aLODGroup = aNewLod->NewGroup();
- // aLODGroup->AddPrimitiveArray (aNodePoints);
- // }
- // return;
- // }
- //}
if (theIsElement)
{
Standard_Integer aMaxNodesNb;
}
}
+#include <Prs3d_Root.hxx>
+
//================================================================
// Function : drawArrays
// Purpose :
if (isPolygons && theFillAsp->FrontMaterial().Transparency() < 0.01)
{
Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup (theBasePrs);
+ //Prs3d_Root::NewGroup ( theBasePrs );
+ //Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup ( theBasePrs );
theFillAsp->SetEdgeOff();
if (isPolylines && !theIsPolygonsEdgesOff)
{
Handle (Graphic3d_Group) aLGroup = aNewLod->NewGroup (theBasePrs);
+ //Prs3d_Root::NewGroup ( theBasePrs );
+ //Handle (Graphic3d_Group) aLGroup = Prs3d_Root::CurrentGroup ( theBasePrs );
theFillAsp->SetEdgeOff();
if (theIsSelected)
if (isLinkPolylines)
{
Handle (Graphic3d_Group) aBeamGroup = aNewLod->NewGroup (theBasePrs);
+ //Prs3d_Root::NewGroup ( theBasePrs );
+ //Handle (Graphic3d_Group) aBeamGroup = Prs3d_Root::CurrentGroup ( theBasePrs );
theFillAsp->SetEdgeOff();
if (!theIsSelected)
if (isPolygons && theFillAsp->FrontMaterial().Transparency() >= 0.01)
{
Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup (theBasePrs);
+ //Prs3d_Root::NewGroup ( theBasePrs );
+ //Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup ( theBasePrs );
theFillAsp->SetEdgeOff();
myHilightDrawer->SetDouble ( MeshVS_DA_MarkerScale, 2.0 );
}
+//================================================================
+// Function : HasLevelsOfDetail
+// Purpose :
+//================================================================
+Standard_Boolean MeshVS_Mesh::HasLevelsOfDetail() const
+{
+ return !myLODDataSources.IsEmpty();
+}
+
+//================================================================
+// Function : ComputeLods
+// Purpose :
+//================================================================
+void MeshVS_Mesh::ComputeLods (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode)
+{
+ for (Standard_Integer aLodBldrIdx = 1; aLodBldrIdx <= myBuilders.Length(); ++aLodBldrIdx)
+ {
+ const Handle(MeshVS_LODBuilder) aLodBldr = Handle(MeshVS_LODBuilder)::DownCast (myBuilders.Value (aLodBldrIdx));
+ if (aLodBldr.IsNull())
+ continue;
+
+ const TColStd_PackedMapOfInteger aTrgIdxs = aLodBldr->GetDataSource()->GetAllElements();
+ if (!aTrgIdxs.IsEmpty())
+ aLodBldr->Build (thePrs, aTrgIdxs, TColStd_PackedMapOfInteger(), Standard_True, theMode);
+ }
+}
+
//================================================================
// Function : Compute
// Purpose :
thePresentation->Clear();
Standard_Integer len = myBuilders.Length();
if ( theMode > 0 )
+ {
for ( Standard_Integer i=1; i<=len; i++ )
{
Handle (MeshVS_PrsBuilder) aCurrent = myBuilders.Value ( i );
aCurrent->Build ( thePresentation, aElems, aElemsToExclude, Standard_True, theMode );
}
}
-
- if (myLODDataSources.Size() > 0)
- {
- for (Standard_Integer aLodBldrIdx = 1; aLodBldrIdx <= myBuilders.Length(); ++aLodBldrIdx)
- {
- const Handle(MeshVS_LODBuilder) aLodBldr = Handle(MeshVS_LODBuilder)::DownCast (myBuilders.Value (aLodBldrIdx));
- if (aLodBldr.IsNull() || !aLodBldr->TestFlags (theMode))
- continue;
-
- const TColStd_PackedMapOfInteger aVertIdxs = aLodBldr->GetDataSource()->GetAllNodes();
- const TColStd_PackedMapOfInteger aTrgIdxs = aLodBldr->GetDataSource()->GetAllElements();
- if (HasNodes)
- aLodBldr->Build (thePresentation, aVertIdxs, aNodesToExclude, Standard_False, theMode);
- if (HasElements)
- aLodBldr->Build (thePresentation, aTrgIdxs, aElemsToExclude, Standard_True, theMode);
- }
}
if ( ShowComputeTime )
//! Returns True if the given owner represents a whole mesh.
Standard_EXPORT virtual Standard_Boolean IsWholeMeshOwner (const Handle(SelectMgr_EntityOwner)& theOwner) const;
+ Standard_EXPORT virtual Standard_Boolean HasLevelsOfDetail() const Standard_OVERRIDE;
+
friend class MeshVS_PrsBuilder;
protected:
+ Standard_EXPORT virtual void ComputeLods (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode = 0) Standard_OVERRIDE;
+
//! Stores all vertices that belong to one of the faces to the given map
//! @param theAllElements [in] the map of all mesh elements
//! @param theNbMaxFaceNodes [in] the maximum amount of nodes per face, retrieved from drawer
Standard_ASSERT_RAISE (theFrom < theTo,
"The upper boundary of the interval must be greater than lower one!");
- if (theIdOfLOD < 0 || theIdOfLOD > myLODManager->NbOfDetailLevels())
+ if (myLODManager.IsNull() || theIdOfLOD < 0 || theIdOfLOD > myLODManager->NbOfDetailLevels())
return;
myLODManager->SetRange (theIdOfLOD, theFrom, theTo);
const Standard_Integer theMode)
{
Handle(Prs3d_Presentation) aStruct3d = thePrs->Presentation();
- Compute (thePrsMgr, aStruct3d, theMode);
+ if (!HasLevelsOfDetail())
+ Compute (thePrsMgr, aStruct3d, theMode);
+ else
+ ComputeLods (thePrsMgr, aStruct3d, theMode);
UpdateTransformation (aStruct3d);
aStruct3d->SetClipPlanes (myClipPlanes);
aStruct3d->SetTransformPersistence (GetTransformPersistenceMode(), GetTransformPersistencePoint());
{
return myIsMutable;
}
+
+// =======================================================================
+// function : ComputeLods
+// purpose :
+// =======================================================================
+void PrsMgr_PresentableObject::ComputeLods (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/,
+ const Handle(Prs3d_Presentation)& /*thePrs*/,
+ const Standard_Integer /*theMode*/)
+{
+ if (HasLevelsOfDetail())
+ {
+ Standard_NotImplemented::Raise ("cannot compute levels of detail");
+ }
+}
+
+// =======================================================================
+// function : HasLevelsOfDetail
+// purpose :
+// =======================================================================
+Standard_Boolean PrsMgr_PresentableObject::HasLevelsOfDetail() const
+{
+ return Standard_False;
+}
//! Returns parent of current object in scene hierarchy.
Standard_EXPORT PrsMgr_PresentableObjectPointer Parent() const;
+ Standard_EXPORT virtual Standard_Boolean HasLevelsOfDetail() const;
+
friend class PrsMgr_Presentation;
friend class PrsMgr_PresentationManager;
Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
Standard_EXPORT virtual ~PrsMgr_PresentableObject();
-
+
+ Standard_EXPORT virtual void ComputeLods (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode = 0);
+
//! Calculates the 3D view aPresentation and its
//! updates. The latter are managed by aPresentationManager.
//! aPresentableObject has the display mode aMode;
# iges shapes. the following sequence of commands creates both
# stl and brep files for the iges shape
##########################################################################
-igesbrep $aPathToData/iges/bearing.iges res *
-vdisplay res
-# write created brep to file
-save res $aTmpFolder/bearing.brep
-trinfo res
-# copy maximal deflection value, then re-mesh the shape with proper
-# deflection
-tclean res
-incmesh res $maxDeflection
-# save corresponding stl with the same triangulation as will be used
-# for generaion of LODs
-writestl res $aTmpFolder/bearing.stl
+# igesbrep $aPathToData/iges/bearing.iges res *
+# vdisplay res
+# # write created brep to file
+# save res $aTmpFolder/bearing.brep
+# trinfo res
+# # copy maximal deflection value, then re-mesh the shape with proper
+# # deflection
+# tclean res
+# incmesh res $maxDeflection
+# # save corresponding stl with the same triangulation as will be used
+# # for generaion of LODs
+# writestl res $aTmpFolder/bearing.stl