mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
df78626bf5 | ||
|
43a665e7af | ||
|
8bed5c1eb4 | ||
|
87a0e40c08 | ||
|
3969f2848a | ||
|
5efc1678e3 | ||
|
3d7e35768f | ||
|
05286d6875 | ||
|
a96ac42dfd |
@@ -77,6 +77,13 @@ Graphic3d_InitialisationError.hxx
|
||||
Graphic3d_LevelOfTextureAnisotropy.hxx
|
||||
Graphic3d_ListIteratorOfListOfShortReal.hxx
|
||||
Graphic3d_ListOfShortReal.hxx
|
||||
Graphic3d_LOD.hxx
|
||||
Graphic3d_LOD.cxx
|
||||
Graphic3d_LODSelector.hxx
|
||||
Graphic3d_LODDistanceSelector.hxx
|
||||
Graphic3d_LODDistanceSelector.cxx
|
||||
Graphic3d_LODManager.hxx
|
||||
Graphic3d_LODManager.cxx
|
||||
Graphic3d_MapIteratorOfMapOfStructure.hxx
|
||||
Graphic3d_MapOfObject.hxx
|
||||
Graphic3d_MapOfStructure.hxx
|
||||
|
@@ -28,6 +28,8 @@
|
||||
|
||||
class Graphic3d_GraphicDriver;
|
||||
class Graphic3d_StructureManager;
|
||||
class Graphic3d_LOD;
|
||||
class Graphic3d_LODManager;
|
||||
|
||||
//! Low-level graphic structure interface
|
||||
class Graphic3d_CStructure : public Standard_Transient
|
||||
@@ -78,6 +80,14 @@ public:
|
||||
//! Get z layer ID
|
||||
Graphic3d_ZLayerId ZLayer() const { return myZLayer; }
|
||||
|
||||
//! Returns LOD manager for this structure. If the structure
|
||||
//! is not represented through LODs, the return value will
|
||||
//! be NULL pointer
|
||||
const Handle(Graphic3d_LODManager)& GetLODManager() const
|
||||
{
|
||||
return myLODManager;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Update structure visibility state
|
||||
@@ -112,9 +122,27 @@ public:
|
||||
//! Create new group within this structure
|
||||
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;
|
||||
|
||||
//! Remove group from this structure
|
||||
virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) = 0;
|
||||
|
||||
//! Returns the number of LODs of the structure
|
||||
virtual Standard_Integer NbDetailLevels() const = 0;
|
||||
|
||||
//! 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
|
||||
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;
|
||||
@@ -157,6 +185,7 @@ protected:
|
||||
Graphic3d_SequenceOfGroup myGroups;
|
||||
Graphic3d_BndBox4f myBndBox;
|
||||
Graphic3d_SequenceOfHClipPlane myClipPlanes;
|
||||
Handle(Graphic3d_LODManager) myLODManager;
|
||||
|
||||
public:
|
||||
|
||||
|
64
src/Graphic3d/Graphic3d_LOD.cxx
Normal file
64
src/Graphic3d/Graphic3d_LOD.cxx
Normal file
@@ -0,0 +1,64 @@
|
||||
// Created on: 2015-10-29
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_LOD.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (Graphic3d_LOD, Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
// function : Destructor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Graphic3d_LOD::~Graphic3d_LOD()
|
||||
{
|
||||
Clear (Standard_True);
|
||||
myGroups.Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetRange
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_LOD::SetRange (const Standard_Real theFrom, const Standard_Real theTo)
|
||||
{
|
||||
Standard_ASSERT_RAISE (theFrom < theTo,
|
||||
"The upper boundary of the interval must be greater than lower one!");
|
||||
|
||||
myRange = Graphic3d_RangeOfLOD (theFrom, theTo);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Clear
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_LOD::Clear (const Standard_Boolean theWithDestruction)
|
||||
{
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
aGroupIter.ChangeValue()->Clear();
|
||||
}
|
||||
|
||||
if (!theWithDestruction)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (!myGroups.IsEmpty())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = myGroups.First();
|
||||
aGroup->Remove();
|
||||
myGroups.Remove (1);
|
||||
}
|
||||
}
|
128
src/Graphic3d/Graphic3d_LOD.hxx
Normal file
128
src/Graphic3d/Graphic3d_LOD.hxx
Normal file
@@ -0,0 +1,128 @@
|
||||
// Created on: 2015-10-29
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_LOD_Header
|
||||
#define _Graphic3d_LOD_Header
|
||||
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_SequenceOfGroup.hxx>
|
||||
#include <Graphic3d_Structure.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
//! This structure is used for ranged LODs to store the lower and upper
|
||||
//! boundaries of the interval where the LOD is visible.
|
||||
//! It also performs the comparison that checks if the given value
|
||||
//! is in or out of the range.
|
||||
struct Graphic3d_RangeOfLOD
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructs a range with the given boundaries
|
||||
Graphic3d_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!");
|
||||
}
|
||||
|
||||
//! Returns true, if the given value is between the lower and
|
||||
//! upper boundaries
|
||||
Standard_Boolean IsIn (const Standard_Real theVal) const
|
||||
{
|
||||
return (myFrom < theVal) && (theVal < myTo);
|
||||
}
|
||||
|
||||
Standard_Boolean IsLess (const Standard_Real theVal) const
|
||||
{
|
||||
return theVal < myFrom;
|
||||
}
|
||||
|
||||
Standard_Boolean IsGreater (const Standard_Real theVal) const
|
||||
{
|
||||
return myTo < theVal;
|
||||
}
|
||||
|
||||
bool operator < (const Graphic3d_RangeOfLOD& theOther) const
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
//! Base class for level of detail representation.
|
||||
//! It provides an interface to create and customize graphic groups for
|
||||
//! the LOD and contains information about the range for ranged LODs.
|
||||
class Graphic3d_LOD : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
|
||||
//! Destroys graphic groups of the LOD
|
||||
Standard_EXPORT virtual ~Graphic3d_LOD();
|
||||
|
||||
Standard_EXPORT void SetRange (const Standard_Real theFrom, const Standard_Real theTo);
|
||||
|
||||
Standard_EXPORT const Graphic3d_RangeOfLOD& GetRange() const
|
||||
{
|
||||
return myRange;
|
||||
}
|
||||
|
||||
//! Create a new group within this LOD
|
||||
Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& /*theParentStruct*/)
|
||||
{
|
||||
return NULL;
|
||||
};
|
||||
|
||||
const Graphic3d_SequenceOfGroup& GetDrawGroups() const
|
||||
{
|
||||
return myGroups;
|
||||
}
|
||||
|
||||
//! If theWithDestruction is true, all the graphic groups of LOD will be destroyed
|
||||
//! and new group must be created for further displaying.
|
||||
//! If theWithDestruction is false, all the data of groups is reset to defauls
|
||||
//! so it is threated like empty.
|
||||
Standard_EXPORT virtual void Clear (const Standard_Boolean theWithDestruction);
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT (Graphic3d_LOD, Standard_Transient)
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates a new LOD that is visible from any distance
|
||||
Standard_EXPORT Graphic3d_LOD() : myRange (-DBL_MAX, DBL_MAX) {};
|
||||
|
||||
protected:
|
||||
Graphic3d_SequenceOfGroup myGroups;
|
||||
Graphic3d_RangeOfLOD myRange;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (Graphic3d_LOD, Standard_Transient)
|
||||
|
||||
#endif // _Graphic3d_LOD_Header
|
34
src/Graphic3d/Graphic3d_LODDistanceSelector.cxx
Normal file
34
src/Graphic3d/Graphic3d_LODDistanceSelector.cxx
Normal file
@@ -0,0 +1,34 @@
|
||||
// Created on: 2015-11-25
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_BndBox4f.hxx>
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_CStructure.hxx>
|
||||
#include <Graphic3d_LODDistanceSelector.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (Graphic3d_LODDistanceSelector, Graphic3d_LODSelector)
|
||||
|
||||
//=======================================================================
|
||||
// function : ComputeMetric
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Real Graphic3d_LODDistanceSelector::ComputeMetric (const Handle(Graphic3d_CStructure)& theParentStructure,
|
||||
const Handle(Graphic3d_Camera)& theCamera)
|
||||
{
|
||||
const Graphic3d_BndBox4f& aBndBox = theParentStructure->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();
|
||||
}
|
41
src/Graphic3d/Graphic3d_LODDistanceSelector.hxx
Normal file
41
src/Graphic3d/Graphic3d_LODDistanceSelector.hxx
Normal file
@@ -0,0 +1,41 @@
|
||||
// Created on: 2015-11-25
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_LODDistanceSelector_Header
|
||||
#define _Graphic3d_LODDistanceSelector_Header
|
||||
|
||||
#include <Graphic3d_LODSelector.hxx>
|
||||
|
||||
class Graphic3d_CStructure;
|
||||
class Graphic3d_Camera;
|
||||
|
||||
//! This class implements computation of distance metrics for determinig
|
||||
//! LOD visibility. It computes distance from center of geometry of the object
|
||||
//! to camera's eye position.
|
||||
class Graphic3d_LODDistanceSelector : public Graphic3d_LODSelector
|
||||
{
|
||||
public:
|
||||
Standard_EXPORT Graphic3d_LODDistanceSelector() {};
|
||||
Standard_EXPORT virtual ~Graphic3d_LODDistanceSelector() {};
|
||||
|
||||
Standard_EXPORT virtual Standard_Real ComputeMetric (const Handle(Graphic3d_CStructure)& theParentStructure,
|
||||
const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT (Graphic3d_LODDistanceSelector, Graphic3d_LODSelector)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (Graphic3d_LODDistanceSelector, Graphic3d_LODSelector)
|
||||
|
||||
#endif // _Graphic3d_LODDistanceSelector_Header
|
184
src/Graphic3d/Graphic3d_LODManager.cxx
Normal file
184
src/Graphic3d/Graphic3d_LODManager.cxx
Normal file
@@ -0,0 +1,184 @@
|
||||
// Created on: 2015-11-25
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_LOD.hxx>
|
||||
#include <Graphic3d_LODManager.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (Graphic3d_LODManager, Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
// function : Creation
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Graphic3d_LODManager::Graphic3d_LODManager (const Handle(Graphic3d_Structure)& theParentStructure)
|
||||
: myLODIndexes (NULL),
|
||||
myIsToSortLODs (Standard_False),
|
||||
myCurrentLODIdx (-1),
|
||||
mySelector (new Graphic3d_LODDistanceSelector())
|
||||
{
|
||||
myStructure = theParentStructure.operator->();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Destructor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Graphic3d_LODManager::~Graphic3d_LODManager()
|
||||
{
|
||||
Clear (Standard_True);
|
||||
|
||||
myLODs.Clear();
|
||||
myLODIndexes.Nullify();
|
||||
mySelector.Nullify();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : HasLODToDisplay
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d_LODManager::HasLODToDisplay (const Handle(Graphic3d_Camera)& theCamera)
|
||||
{
|
||||
if (theCamera->WorldViewProjState() == myPrevCameraState && myCurrentLODIdx != -1)
|
||||
return Standard_True;
|
||||
|
||||
if (myIsToSortLODs)
|
||||
sortLODs();
|
||||
|
||||
myPrevCameraState = theCamera->WorldViewProjState();
|
||||
const Standard_Real aMetric = mySelector->ComputeMetric (myStructure->CStructure(), theCamera);
|
||||
if (myLODs.FindKey (1)->GetRange().IsLess (aMetric))
|
||||
{
|
||||
myCurrentLODIdx = -1;
|
||||
return Standard_False;
|
||||
}
|
||||
else if (myLODs.FindKey (myLODs.Extent())->GetRange().IsGreater (aMetric))
|
||||
{
|
||||
myCurrentLODIdx = myLODs.Extent();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer aLODIdx = 1; aLODIdx <= myLODs.Extent(); ++aLODIdx)
|
||||
{
|
||||
if (myLODs.FindKey (aLODIdx)->GetRange().IsIn (aMetric))
|
||||
{
|
||||
myCurrentLODIdx = aLODIdx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetRange
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_LODManager::SetRange (Standard_Integer theLODIdx,
|
||||
const Standard_Real theFrom,
|
||||
const Standard_Real theTo)
|
||||
{
|
||||
if (theLODIdx < 1 || theLODIdx > myLODs.Extent())
|
||||
return;
|
||||
|
||||
myLODs.FindKey (theLODIdx)->SetRange (theFrom, theTo);
|
||||
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 :
|
||||
//=======================================================================
|
||||
const Graphic3d_SequenceOfGroup& Graphic3d_LODManager::GetCurrentGroups() const
|
||||
{
|
||||
return myLODs.FindKey (myCurrentLODIdx)->GetDrawGroups();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetCombinedBndBox
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_LODManager::GetCombinedBndBox (Graphic3d_BndBox4f& theBndBox) const
|
||||
{
|
||||
for (Standard_Integer aLODIdx = 1; aLODIdx <= myLODs.Extent(); ++aLODIdx)
|
||||
{
|
||||
const Graphic3d_SequenceOfGroup& aGroups = myLODs.FindKey (aLODIdx)->GetDrawGroups();
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
theBndBox.Combine (aGroupIter.Value()->BoundingBox());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsEmpty
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d_LODManager::IsEmpty() const
|
||||
{
|
||||
for (Standard_Integer aLODIdx = 1; aLODIdx <= myLODs.Extent(); ++aLODIdx)
|
||||
{
|
||||
const Graphic3d_SequenceOfGroup& aGroups = myLODs.FindKey (aLODIdx)->GetDrawGroups();
|
||||
if (!aGroups.IsEmpty())
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Clear
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_LODManager::Clear (const Standard_Boolean theWithDestruction)
|
||||
{
|
||||
for (Standard_Integer aLODIdx = 1; aLODIdx <= myLODs.Extent(); ++aLODIdx)
|
||||
{
|
||||
myLODs.FindKey (aLODIdx)->Clear (theWithDestruction);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetLODById
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
const Handle(Graphic3d_LOD)& Graphic3d_LODManager::GetLODById (const Standard_Integer theLODIdx)
|
||||
{
|
||||
Standard_ASSERT_RAISE (theLODIdx > 0 || theLODIdx <= myLODs.Size(),
|
||||
"Index of LOD is out of range");
|
||||
|
||||
return myLODs.FindKey (theLODIdx);
|
||||
}
|
||||
|
||||
Standard_Boolean Graphic3d_LODManager::HasLOD (const Handle(Graphic3d_LOD)& theLOD) const
|
||||
{
|
||||
return myLODs.Contains (theLOD);
|
||||
}
|
133
src/Graphic3d/Graphic3d_LODManager.hxx
Normal file
133
src/Graphic3d/Graphic3d_LODManager.hxx
Normal file
@@ -0,0 +1,133 @@
|
||||
// Created on: 2015-11-25
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_LODManager_Header
|
||||
#define _Graphic3d_LODManager_Header
|
||||
|
||||
#include <Graphic3d_CStructure.hxx>
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_LODSelector.hxx>
|
||||
#include <Graphic3d_LODDistanceSelector.hxx>
|
||||
#include <Graphic3d_SequenceOfGroup.hxx>
|
||||
#include <Graphic3d_StructurePtr.hxx>
|
||||
#include <NCollection_IndexedMap.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
|
||||
class Graphic3d_LOD;
|
||||
|
||||
typedef NCollection_IndexedMap<Handle(Graphic3d_LOD)> Graphic3d_MapOfLODs;
|
||||
|
||||
//! This class is used to manage all the LODs of one Graphic3d_Structure.
|
||||
//! It provides an interface for the following actions:
|
||||
//! - addition of a new LOD;
|
||||
//! - management of current method for LOD metrics calculation;
|
||||
//! - access to LODs and its characteristics, such as quantity, range,
|
||||
//! combined bounding box.
|
||||
//! The class also runs a procedure that picks the LOD that should be
|
||||
//! rendered according to the current state of camera and stores choosen
|
||||
//! LOD index.
|
||||
class Graphic3d_LODManager : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
|
||||
//! Nullifies the pointer to current selector and clears used data maps,
|
||||
//! destroys the LODs used, so they can not be referenced to after the destruction
|
||||
//! of corresponding LOD manager
|
||||
Standard_EXPORT virtual ~Graphic3d_LODManager();
|
||||
|
||||
//! Sets up a method for LOD metrics computation
|
||||
Standard_EXPORT void SetSelector (const Handle(Graphic3d_LODSelector)& theSelector)
|
||||
{
|
||||
mySelector = theSelector;
|
||||
}
|
||||
|
||||
//! Returns a number of addded detail levels
|
||||
Standard_EXPORT inline Standard_Integer NbOfDetailLevels() const
|
||||
{
|
||||
return myLODs.Size();
|
||||
}
|
||||
|
||||
//! For ranged LODs, sets the distance interval where the LOD will be visible.
|
||||
//! @param theLODIdx the index of LOD in sorted list
|
||||
Standard_EXPORT void SetRange (const Standard_Integer theLODIdx,
|
||||
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);
|
||||
|
||||
//! Returns graphic groups of the LOD that must be displayed according to the current
|
||||
//! camera state
|
||||
Standard_EXPORT const Graphic3d_SequenceOfGroup& GetCurrentGroups() const;
|
||||
|
||||
Standard_EXPORT virtual Handle(Graphic3d_LOD) AddNewLOD() = 0;
|
||||
|
||||
//! Returns combined bounding box for all LOD groups that were added to this
|
||||
//! manager
|
||||
Standard_EXPORT void GetCombinedBndBox (Graphic3d_BndBox4f& theBndBox) const;
|
||||
|
||||
//! Returns false if at least one of LODs has non-empty sequence of Graphic3d_Groups
|
||||
Standard_EXPORT Standard_Boolean IsEmpty() const;
|
||||
|
||||
//! Iterates through added LODs and clears up its resources.
|
||||
//! If theWithDestruction is true, all the graphic groups of each LOD will be destroyed
|
||||
//! and new group must be created for further displaying.
|
||||
//! If theWithDestruction is false, all the data of groups is reset to defauls
|
||||
//! so it is threated like empty.
|
||||
Standard_EXPORT void Clear (const Standard_Boolean theWithDestruction);
|
||||
|
||||
//! The indexes are from 1 to NbOfDetailLevels(). The ID of the element corresponds
|
||||
//! to the index of the LOD in the map of LOD manager. Therefore, 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 const Handle(Graphic3d_LOD)& GetLODById (const Standard_Integer theLODIdx);
|
||||
|
||||
//! Checks if the given LOD is added to this manager
|
||||
Standard_EXPORT Standard_Boolean HasLOD (const Handle(Graphic3d_LOD)& theLOD) const;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT (Graphic3d_LODManager, Standard_Transient)
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates an empty manager with invalid LOD metrics calculation method
|
||||
Standard_EXPORT Graphic3d_LODManager (const Handle(Graphic3d_Structure)& theParentStructure);
|
||||
|
||||
//! Sorts LODs in the map according to its ranges to improve search for LOD to display.
|
||||
//! After the sort is done, flag myIsToSortLODs will be set to false.
|
||||
Standard_EXPORT virtual void sortLODs() {};
|
||||
|
||||
protected:
|
||||
Graphic3d_MapOfLODs myLODs; //!< Map of LODs
|
||||
Handle(TColStd_HArray1OfInteger) myLODIndexes; //!< Array of LOD indexes, for sorting purposes
|
||||
Standard_Boolean myIsToSortLODs; //!< Is true when LODs must be sorted before picking procedure. For example, when new LOD was added
|
||||
|
||||
private:
|
||||
Standard_Integer myCurrentLODIdx; //!< Index of current LOD that should be rendered; is -1 by default.
|
||||
Handle(Graphic3d_LODSelector) mySelector; //!< A wrapper that performs measurement of LOD metrics
|
||||
Graphic3d_StructurePtr myStructure; //!< A pointer to graphic structure that is common for all LODs
|
||||
Graphic3d_WorldViewProjState myPrevCameraState; //!< Previous state of the camera for current LOD detection procedure
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (Graphic3d_LODManager, Standard_Transient)
|
||||
|
||||
#endif //_Graphic3d_LODManager_Header
|
42
src/Graphic3d/Graphic3d_LODSelector.hxx
Normal file
42
src/Graphic3d/Graphic3d_LODSelector.hxx
Normal file
@@ -0,0 +1,42 @@
|
||||
// Created on: 2015-11-25
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_LODSelector_Header
|
||||
#define _Graphic3d_LODSelector_Header
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
class Graphic3d_CStructure;
|
||||
class Graphic3d_Camera;
|
||||
|
||||
//! Base interface for classes implementing computation of
|
||||
//! LOD visibility metrics
|
||||
class Graphic3d_LODSelector : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
|
||||
//! Computes the value of LOD visibility metrics according to current camera state
|
||||
//! and choosen approach for metrics calculation
|
||||
virtual Standard_Real ComputeMetric (const Handle(Graphic3d_CStructure)& theParentStructure,
|
||||
const Handle(Graphic3d_Camera)& theCamera) = 0;
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE (Graphic3d_LODSelector, Standard_Transient)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (Graphic3d_LODSelector, Standard_Transient)
|
||||
|
||||
#endif // _Graphic3d_LODSelector_Header
|
@@ -24,6 +24,7 @@
|
||||
#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>
|
||||
@@ -186,6 +187,12 @@ void Graphic3d_Structure::Remove()
|
||||
((Graphic3d_Structure *)myAncestors.FindKey (aStructIdx))->Remove (APtr, Graphic3d_TOC_DESCENDANT);
|
||||
}
|
||||
|
||||
// Clear LODs graphic groups if there are any
|
||||
if (!myCStructure->GetLODManager().IsNull())
|
||||
{
|
||||
myCStructure->GetLODManager()->Clear (Standard_False);
|
||||
}
|
||||
|
||||
// Destruction of me in the graphic library
|
||||
const Standard_Integer aStructId = myCStructure->Id;
|
||||
myCStructure->GraphicDriver()->RemoveStructure (myCStructure);
|
||||
@@ -485,9 +492,15 @@ Standard_Boolean Graphic3d_Structure::IsEmpty() const
|
||||
}
|
||||
|
||||
// structure is empty:
|
||||
// - in case if it is represented by LODs, all LODs have no graphic groups
|
||||
// - if all these groups are empty
|
||||
// - or if all groups are empty and all their descendants are empty
|
||||
// - or if all its descendants are empty
|
||||
if (!myCStructure->GetLODManager().IsNull())
|
||||
{
|
||||
return myCStructure->GetLODManager()->IsEmpty();
|
||||
}
|
||||
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
if (!aGroupIter.Value()->IsEmpty())
|
||||
@@ -634,6 +647,13 @@ void Graphic3d_Structure::GraphicClear (const Standard_Boolean theWithDestructio
|
||||
return;
|
||||
}
|
||||
|
||||
if (!myCStructure->GetLODManager().IsNull())
|
||||
{
|
||||
myCStructure->GetLODManager()->Clear (theWithDestruction);
|
||||
if (theWithDestruction)
|
||||
myCStructure->Clear();
|
||||
}
|
||||
|
||||
// clean and empty each group
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
@@ -1709,6 +1729,42 @@ Handle(Graphic3d_Group) Graphic3d_Structure::NewGroup()
|
||||
return myCStructure->NewGroup (this);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : NewLOD
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Handle(Graphic3d_LOD) Graphic3d_Structure::NewLOD()
|
||||
{
|
||||
return myCStructure->NewLOD (this);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : NbDetailLevels
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Integer Graphic3d_Structure::NbDetailLevels() const
|
||||
{
|
||||
return myCStructure->NbDetailLevels();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : SetDetailLevelRange
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void Graphic3d_Structure::SetDetailLevelRange (const Standard_Integer theLODIdx, const Standard_Real theFrom, const Standard_Real 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);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Remove
|
||||
//purpose :
|
||||
@@ -1741,9 +1797,16 @@ Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager() const
|
||||
Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
|
||||
{
|
||||
Graphic3d_BndBox4f aBnd;
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
if (myCStructure->GetLODManager().IsNull())
|
||||
{
|
||||
aBnd.Combine (aGroupIter.Value()->BoundingBox());
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
aBnd.Combine (aGroupIter.Value()->BoundingBox());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myCStructure->GetLODManager()->GetCombinedBndBox (aBnd);
|
||||
}
|
||||
return aBnd;
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include <Graphic3d_ZLayerId.hxx>
|
||||
#include <Graphic3d_SequenceOfHClipPlane.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
#include <Graphic3d_SequenceOfGroup.hxx>
|
||||
#include <Graphic3d_TypeOfConnection.hxx>
|
||||
@@ -54,6 +55,7 @@ class Graphic3d_AspectFillArea3d;
|
||||
class Graphic3d_AspectText3d;
|
||||
class Graphic3d_AspectMarker3d;
|
||||
class Graphic3d_DataStructureManager;
|
||||
class Graphic3d_LOD;
|
||||
class Bnd_Box;
|
||||
class gp_Pnt;
|
||||
class Graphic3d_Vector;
|
||||
@@ -254,6 +256,9 @@ public:
|
||||
|
||||
//! Append new group to this structure.
|
||||
Standard_EXPORT Handle(Graphic3d_Group) NewGroup();
|
||||
|
||||
//! Append new LOD to this structure.
|
||||
Standard_EXPORT Handle(Graphic3d_LOD) NewLOD();
|
||||
|
||||
//! Returns the highlight color for the Highlight method
|
||||
//! with the highlight method TOHM_COLOR or TOHM_BOUNDBOX.
|
||||
@@ -479,6 +484,21 @@ public:
|
||||
//! Returns the low-level structure
|
||||
const Handle(Graphic3d_CStructure)& CStructure() const;
|
||||
|
||||
//! Returns number of LODs created for this structure
|
||||
Standard_EXPORT Standard_Integer NbDetailLevels() const;
|
||||
|
||||
//! 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 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;
|
||||
|
||||
|
||||
|
@@ -43,6 +43,10 @@ MeshVS_ElementalColorPrsBuilder.cxx
|
||||
MeshVS_ElementalColorPrsBuilder.hxx
|
||||
MeshVS_EntityType.hxx
|
||||
MeshVS_HArray1OfSequenceOfInteger.hxx
|
||||
MeshVS_LODBuilder.hxx
|
||||
MeshVS_LODBuilder.cxx
|
||||
MeshVS_LODDataSource.hxx
|
||||
MeshVS_LODDataSource.cxx
|
||||
MeshVS_MapIteratorOfMapOfTwoNodes.hxx
|
||||
MeshVS_MapOfTwoNodes.hxx
|
||||
MeshVS_Mesh.cxx
|
||||
|
@@ -56,7 +56,7 @@ class MeshVS_DataSource : public MMgt_TShared
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
//! Returns geometry information about node or element
|
||||
//! ID is the numerical identificator of node or element
|
||||
//! IsElement indicates this ID describe node ( if Standard_False ) or element ( if Standard_True )
|
||||
@@ -67,33 +67,44 @@ public:
|
||||
//! NbNodes is number of nodes. It is recommended this parameter to be set to 1 for node.
|
||||
//! Type is type of node or element (from enumeration). It is recommended this parameter to be set to
|
||||
//! MeshVS_ET_Node for node.
|
||||
Standard_EXPORT virtual Standard_Boolean GetGeom (const Standard_Integer ID, const Standard_Boolean IsElement, TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes, MeshVS_EntityType& Type) const = 0;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean GetGeom (const Standard_Integer ID,
|
||||
const Standard_Boolean IsElement,
|
||||
TColStd_Array1OfReal& Coords,
|
||||
Standard_Integer& NbNodes,
|
||||
MeshVS_EntityType& Type) const = 0;
|
||||
|
||||
//! This method is similar to GetGeom, but returns only element or node type.
|
||||
Standard_EXPORT virtual Standard_Boolean GetGeomType (const Standard_Integer ID, const Standard_Boolean IsElement, MeshVS_EntityType& Type) const = 0;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean GetGeomType (const Standard_Integer ID,
|
||||
const Standard_Boolean IsElement,
|
||||
MeshVS_EntityType& Type) const = 0;
|
||||
|
||||
//! This method returns topology information about 3D-element
|
||||
//! Returns false if element with ID isn't 3D or because other troubles
|
||||
Standard_EXPORT virtual Standard_Boolean Get3DGeom (const Standard_Integer ID, Standard_Integer& NbNodes, Handle(MeshVS_HArray1OfSequenceOfInteger)& Data) const;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Get3DGeom (const Standard_Integer ID,
|
||||
Standard_Integer& NbNodes,
|
||||
Handle(MeshVS_HArray1OfSequenceOfInteger)& Data) const;
|
||||
|
||||
//! This method returns pointer which represents element or node data structure.
|
||||
//! This address will be saved in MeshVS_MeshEntityOwner, so that you can access to data structure fast
|
||||
//! by the method Owner(). In the redefined method you can return NULL.
|
||||
//! ID is the numerical identificator of node or element
|
||||
//! IsElement indicates this ID describe node ( if Standard_False ) or element ( if Standard_True )
|
||||
Standard_EXPORT virtual Standard_Address GetAddr (const Standard_Integer ID, const Standard_Boolean IsElement) const = 0;
|
||||
|
||||
Standard_EXPORT virtual Standard_Address GetAddr (const Standard_Integer ID,
|
||||
const Standard_Boolean IsElement) const = 0;
|
||||
|
||||
//! This method returns information about nodes this element consist of.
|
||||
//! ID is the numerical identificator of element.
|
||||
//! NodeIDs is the output array of nodes IDs in correct order,
|
||||
//! the same as coordinates returned by GetGeom().
|
||||
//! NbNodes is number of nodes (number of items set in NodeIDs).
|
||||
//! Returns False if element does not exist
|
||||
Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer ID, TColStd_Array1OfInteger& NodeIDs, Standard_Integer& NbNodes) const = 0;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer ID,
|
||||
TColStd_Array1OfInteger& NodeIDs,
|
||||
Standard_Integer& NbNodes) const = 0;
|
||||
|
||||
//! This method returns map of all nodes the object consist of.
|
||||
Standard_EXPORT virtual const TColStd_PackedMapOfInteger& GetAllNodes() const = 0;
|
||||
|
||||
|
||||
//! This method returns map of all elements the object consist of.
|
||||
Standard_EXPORT virtual const TColStd_PackedMapOfInteger& GetAllElements() const = 0;
|
||||
|
||||
@@ -105,13 +116,21 @@ public:
|
||||
//! In the redefined method you can return normal with length more then 1, but in this case
|
||||
//! the appearance of element will be more bright than usual. For ordinary brightness you must return
|
||||
//! normal with length 1
|
||||
Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer Id, const Standard_Integer Max, Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer Id,
|
||||
const Standard_Integer Max,
|
||||
Standard_Real& nx,
|
||||
Standard_Real& ny,
|
||||
Standard_Real& nz) const;
|
||||
|
||||
//! This method return normal of node ranknode of face Id,
|
||||
//! which is using for smooth shading presentation.
|
||||
//! Returns false if normal isn't defined.
|
||||
Standard_EXPORT virtual Standard_Boolean GetNodeNormal (const Standard_Integer ranknode, const Standard_Integer ElementId, Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean GetNodeNormal (const Standard_Integer ranknode,
|
||||
const Standard_Integer ElementId,
|
||||
Standard_Real& nx,
|
||||
Standard_Real& ny,
|
||||
Standard_Real& nz) const;
|
||||
|
||||
//! This method puts components of normal vectors at each node of a mesh face (at each face of a mesh volume)
|
||||
//! into the output array.
|
||||
//! Returns false if some problem was detected during calculation of normals.
|
||||
@@ -123,13 +142,18 @@ public:
|
||||
//! volume: normals to all faces of the volume are computed (not for each node!).
|
||||
//! MaxNodes is maximal number of nodes an element can consist of.
|
||||
//! Normals contains the result.
|
||||
Standard_EXPORT virtual Standard_Boolean GetNormalsByElement (const Standard_Integer Id, const Standard_Boolean IsNodal, const Standard_Integer MaxNodes, Handle(TColStd_HArray1OfReal)& Normals) const;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean GetNormalsByElement (const Standard_Integer Id,
|
||||
const Standard_Boolean IsNodal,
|
||||
const Standard_Integer MaxNodes,
|
||||
Handle(TColStd_HArray1OfReal)& Normals) const;
|
||||
|
||||
//! This method returns map of all groups the object contains.
|
||||
Standard_EXPORT virtual void GetAllGroups (TColStd_PackedMapOfInteger& Ids) const;
|
||||
|
||||
|
||||
//! This method returns map of all group elements.
|
||||
Standard_EXPORT virtual Standard_Boolean GetGroup (const Standard_Integer Id, MeshVS_EntityType& Type, TColStd_PackedMapOfInteger& Ids) const;
|
||||
Standard_EXPORT virtual Standard_Boolean GetGroup (const Standard_Integer Id,
|
||||
MeshVS_EntityType& Type,
|
||||
TColStd_PackedMapOfInteger& Ids) const;
|
||||
|
||||
//! This method returns pointer which represents group data structure.
|
||||
//! This address will be saved in MeshVS_MeshOwner, so that you can access to data structure fast
|
||||
@@ -156,7 +180,13 @@ public:
|
||||
//! Returns True if something is detected.
|
||||
//! It should be redefined if the advanced mesh selection is
|
||||
//! activated. Default implementation returns False.
|
||||
Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs, const Standard_Real X, const Standard_Real Y, const Standard_Real aTol, Handle(TColStd_HPackedMapOfInteger)& Nodes, Handle(TColStd_HPackedMapOfInteger)& Elements, Standard_Real& DMin);
|
||||
Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs,
|
||||
const Standard_Real X,
|
||||
const Standard_Real Y,
|
||||
const Standard_Real aTol,
|
||||
Handle(TColStd_HPackedMapOfInteger)& Nodes,
|
||||
Handle(TColStd_HPackedMapOfInteger)& Elements,
|
||||
Standard_Real& DMin);
|
||||
|
||||
//! Returns maps of entities (nodes and elements) detected
|
||||
//! by mouse selection with rectangular box (XMin, YMin, XMax, YMax)
|
||||
@@ -164,45 +194,39 @@ public:
|
||||
//! Returns True if something is detected.
|
||||
//! It should be redefined if the advanced mesh selection is
|
||||
//! activated. Default implementation returns False.
|
||||
Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs, const Standard_Real XMin, const Standard_Real YMin, const Standard_Real XMax, const Standard_Real YMax, const Standard_Real aTol, Handle(TColStd_HPackedMapOfInteger)& Nodes, Handle(TColStd_HPackedMapOfInteger)& Elements);
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs,
|
||||
const Standard_Real XMin,
|
||||
const Standard_Real YMin,
|
||||
const Standard_Real XMax,
|
||||
const Standard_Real YMax,
|
||||
const Standard_Real aTol,
|
||||
Handle(TColStd_HPackedMapOfInteger)& Nodes,
|
||||
Handle(TColStd_HPackedMapOfInteger)& Elements);
|
||||
|
||||
//! Returns maps of entities (nodes and elements) detected
|
||||
//! by mouse selection with the polyline <Polyline>
|
||||
//! on the current veiw plane, with the tolerance aTol.
|
||||
//! Returns True if something is detected.
|
||||
//! It should be redefined if the advanced mesh selection is
|
||||
//! activated. Default implementation returns False.
|
||||
Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs, const TColgp_Array1OfPnt2d& Polyline, const Bnd_Box2d& aBox, const Standard_Real aTol, Handle(TColStd_HPackedMapOfInteger)& Nodes, Handle(TColStd_HPackedMapOfInteger)& Elements);
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs,
|
||||
const TColgp_Array1OfPnt2d& Polyline,
|
||||
const Bnd_Box2d& aBox,
|
||||
const Standard_Real aTol,
|
||||
Handle(TColStd_HPackedMapOfInteger)& Nodes,
|
||||
Handle(TColStd_HPackedMapOfInteger)& Elements);
|
||||
|
||||
//! Filter out the maps of mesh entities so as to keep
|
||||
//! only the entities that are allowed to be selected
|
||||
//! according to the current context.
|
||||
//! Returns True if any of the maps has been changed.
|
||||
//! It should be redefined if the advanced mesh selection is
|
||||
//! activated. Default implementation returns False.
|
||||
Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs, Handle(TColStd_HPackedMapOfInteger)& Nodes, Handle(TColStd_HPackedMapOfInteger)& Elements);
|
||||
|
||||
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs,
|
||||
Handle(TColStd_HPackedMapOfInteger)& Nodes,
|
||||
Handle(TColStd_HPackedMapOfInteger)& Elements);
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(MeshVS_DataSource,MMgt_TShared)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _MeshVS_DataSource_HeaderFile
|
||||
|
168
src/MeshVS/MeshVS_LODBuilder.cxx
Normal file
168
src/MeshVS/MeshVS_LODBuilder.cxx
Normal file
@@ -0,0 +1,168 @@
|
||||
// Created on: 2015-11-25
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_LOD.hxx>
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_LODBuilder.hxx>
|
||||
#include <MeshVS_MapOfTwoNodes.hxx>
|
||||
#include <MeshVS_MeshPrsBuilder.hxx>
|
||||
#include <MeshVS_SymmetricPairHasher.hxx>
|
||||
#include <MeshVS_Tool.hxx>
|
||||
#include <TColStd_HPackedMapOfInteger.hxx>
|
||||
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (MeshVS_LODBuilder, MeshVS_MeshPrsBuilder)
|
||||
|
||||
//=======================================================================
|
||||
// function : Creation
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
MeshVS_LODBuilder::MeshVS_LODBuilder (const Handle(MeshVS_Mesh)& theParentMesh,
|
||||
const MeshVS_DisplayModeFlags& theFlags,
|
||||
const Handle(MeshVS_LODDataSource)& theDataSource,
|
||||
const Standard_Integer theId,
|
||||
const MeshVS_BuilderPriority& thePriority)
|
||||
: MeshVS_MeshPrsBuilder (theParentMesh, theFlags, theDataSource, theId, thePriority)
|
||||
{}
|
||||
|
||||
//================================================================
|
||||
// Function : DrawArrays
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_LODBuilder::DrawArrays (const Handle(Prs3d_Presentation)& theBasePrs,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& thePolygons,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& theLines,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& theLinkLines,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& theVolumesInShad,
|
||||
const Standard_Boolean theIsPolygonsEdgesOff,
|
||||
const Standard_Boolean theIsSelected,
|
||||
const Handle(Graphic3d_AspectFillArea3d)& theFillAsp,
|
||||
const Handle(Graphic3d_AspectLine3d)& theLineAsp) const
|
||||
{
|
||||
if (theFillAsp.IsNull())
|
||||
return;
|
||||
|
||||
Standard_Boolean isFacePolygons = (!thePolygons.IsNull() && thePolygons->ItemNumber() > 0),
|
||||
isVolumePolygons = (!theVolumesInShad.IsNull() && theVolumesInShad->ItemNumber() > 0),
|
||||
isPolygons = isFacePolygons || isVolumePolygons,
|
||||
isPolylines = (!theLines.IsNull() && theLines->ItemNumber() > 0),
|
||||
isLinkPolylines = (!theLinkLines.IsNull() && theLinkLines->ItemNumber() > 0);
|
||||
|
||||
Standard_Boolean isSupressBackFaces = Standard_False;
|
||||
Handle(MeshVS_Drawer) aDrawer = GetDrawer();
|
||||
if (!aDrawer.IsNull())
|
||||
{
|
||||
aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, isSupressBackFaces);
|
||||
}
|
||||
|
||||
Aspect_InteriorStyle aStyle;
|
||||
Quantity_Color anIntColor, aBackColor, anEdgeColor;
|
||||
Aspect_TypeOfLine aType;
|
||||
Standard_Real aWidth;
|
||||
|
||||
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 (theBasePrs);
|
||||
|
||||
theFillAsp->SetEdgeOff();
|
||||
|
||||
if (anIntColor != aBackColor)
|
||||
theFillAsp->SetDistinguishOn();
|
||||
else
|
||||
theFillAsp->SetDistinguishOff();
|
||||
|
||||
aGroup->SetClosed (isSupressBackFaces);
|
||||
Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*(theFillAsp.operator->()));
|
||||
if (isSupressBackFaces)
|
||||
{
|
||||
aFillAsp->SuppressBackFace();
|
||||
}
|
||||
aGroup->SetPrimitivesAspect (aFillAsp);
|
||||
|
||||
if (isFacePolygons)
|
||||
{
|
||||
aGroup->AddPrimitiveArray (thePolygons);
|
||||
}
|
||||
|
||||
if (isVolumePolygons)
|
||||
{
|
||||
aGroup->AddPrimitiveArray (theVolumesInShad);
|
||||
}
|
||||
}
|
||||
|
||||
if (isPolylines && !theIsPolygonsEdgesOff)
|
||||
{
|
||||
Handle (Graphic3d_Group) aLGroup = aNewLOD->NewGroup (theBasePrs);
|
||||
|
||||
theFillAsp->SetEdgeOff();
|
||||
if (theIsSelected)
|
||||
aLGroup->SetPrimitivesAspect (theLineAsp);
|
||||
else
|
||||
{
|
||||
aLGroup->SetPrimitivesAspect (theFillAsp);
|
||||
aLGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (anEdgeColor, Aspect_TOL_SOLID, aWidth));
|
||||
}
|
||||
aLGroup->AddPrimitiveArray (theLines);
|
||||
theFillAsp->SetEdgeOn();
|
||||
}
|
||||
|
||||
if (isLinkPolylines)
|
||||
{
|
||||
Handle (Graphic3d_Group) aBeamGroup = aNewLOD->NewGroup (theBasePrs);
|
||||
|
||||
theFillAsp->SetEdgeOff();
|
||||
if (!theIsSelected)
|
||||
aBeamGroup->SetPrimitivesAspect (theFillAsp);
|
||||
aBeamGroup->SetPrimitivesAspect (theLineAsp);
|
||||
aBeamGroup->AddPrimitiveArray (theLinkLines);
|
||||
theFillAsp->SetEdgeOn();
|
||||
}
|
||||
|
||||
if (isPolygons && theFillAsp->FrontMaterial().Transparency() >= 0.01)
|
||||
{
|
||||
Handle (Graphic3d_Group) aGroup = aNewLOD->NewGroup (theBasePrs);
|
||||
|
||||
theFillAsp->SetEdgeOff();
|
||||
|
||||
if (anIntColor != aBackColor)
|
||||
theFillAsp->SetDistinguishOn();
|
||||
else
|
||||
theFillAsp->SetDistinguishOff();
|
||||
|
||||
aGroup->SetClosed (isSupressBackFaces);
|
||||
Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*(theFillAsp.operator->()));
|
||||
if (isSupressBackFaces)
|
||||
{
|
||||
aFillAsp->SuppressBackFace();
|
||||
}
|
||||
aGroup->SetPrimitivesAspect (aFillAsp);
|
||||
|
||||
if (isFacePolygons)
|
||||
{
|
||||
aGroup->AddPrimitiveArray (thePolygons);
|
||||
}
|
||||
|
||||
if (isVolumePolygons)
|
||||
{
|
||||
aGroup->AddPrimitiveArray (theVolumesInShad);
|
||||
}
|
||||
}
|
||||
}
|
59
src/MeshVS/MeshVS_LODBuilder.hxx
Normal file
59
src/MeshVS/MeshVS_LODBuilder.hxx
Normal file
@@ -0,0 +1,59 @@
|
||||
// Created on: 2015-11-25
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _MeshVS_LODBuilder_Header
|
||||
#define _MeshVS_LODBuilder_Header
|
||||
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_MeshPrsBuilder.hxx>
|
||||
#include <MeshVS_LODDataSource.hxx>
|
||||
|
||||
//! The class is used to build graphic groups for one LOD of the presentation.
|
||||
//! The only difference between usual MeshVS_MeshPrsBuilder is in approach to
|
||||
//! filling the presentation: LOD groups are created instead of own groups of
|
||||
//! the presentation.
|
||||
class MeshVS_LODBuilder : public MeshVS_MeshPrsBuilder
|
||||
{
|
||||
public:
|
||||
|
||||
//! Creates builder with certain display mode flags, data source, ID and priority
|
||||
Standard_EXPORT MeshVS_LODBuilder (const Handle(MeshVS_Mesh)& theParentMesh,
|
||||
const MeshVS_DisplayModeFlags& theFlags = MeshVS_DMF_OCCMask,
|
||||
const Handle(MeshVS_LODDataSource)& theDataSource = NULL,
|
||||
const Standard_Integer theId = -1,
|
||||
const MeshVS_BuilderPriority& thePriority = MeshVS_BP_Mesh);
|
||||
|
||||
Standard_EXPORT virtual ~MeshVS_LODBuilder() {};
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT (MeshVS_LODBuilder, MeshVS_PrsBuilder)
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates LOD graphic groups, adds them to base presentation and fills according to the build
|
||||
//! parameters
|
||||
Standard_EXPORT virtual void DrawArrays (const Handle(Prs3d_Presentation)& theBasePrs,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& thePolygons,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& theLines,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& theLinkLines,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& theVolumesInShad,
|
||||
const Standard_Boolean theIsPolygonsEdgesOff,
|
||||
const Standard_Boolean theIsSelected,
|
||||
const Handle(Graphic3d_AspectFillArea3d)& theFillAsp,
|
||||
const Handle(Graphic3d_AspectLine3d)& theLineAsp) const Standard_OVERRIDE;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (MeshVS_LODBuilder, MeshVS_MeshPrsBuilder)
|
||||
|
||||
#endif // _MeshVS_LODBuilder_Header
|
179
src/MeshVS/MeshVS_LODDataSource.cxx
Normal file
179
src/MeshVS/MeshVS_LODDataSource.cxx
Normal file
@@ -0,0 +1,179 @@
|
||||
// Created on: 2015-10-23
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <MeshVS_LODDataSource.hxx>
|
||||
|
||||
#include <Graphic3d_ArrayOfPoints.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_LOD.hxx>
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_MapOfTwoNodes.hxx>
|
||||
#include <MeshVS_MeshPrsBuilder.hxx>
|
||||
#include <MeshVS_SymmetricPairHasher.hxx>
|
||||
#include <MeshVS_Tool.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <TColStd_HPackedMapOfInteger.hxx>
|
||||
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
#include <TColgp_SequenceOfXYZ.hxx>
|
||||
#include <StlMesh_SequenceOfMeshTriangle.hxx>
|
||||
#include <StlMesh_MeshTriangle.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (MeshVS_LODDataSource, MeshVS_DataSource)
|
||||
|
||||
//=======================================================================
|
||||
// function : MeshVS_LODDataSource
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
MeshVS_LODDataSource::MeshVS_LODDataSource (const Handle(StlMesh_Mesh)& theMesh)
|
||||
: myTriangles (1, theMesh->Triangles().Length()),
|
||||
myNodes (1, theMesh->Vertices().Length())
|
||||
{
|
||||
if (theMesh.IsNull())
|
||||
return;
|
||||
|
||||
const TColgp_SequenceOfXYZ& aVerts = theMesh->Vertices();
|
||||
for (Standard_Integer aNodeIdx = 1; aNodeIdx <= aVerts.Length(); ++aNodeIdx)
|
||||
{
|
||||
myNodeIdxs.Add (aNodeIdx);
|
||||
myNodes.ChangeValue (aNodeIdx) = aVerts (aNodeIdx);
|
||||
}
|
||||
|
||||
const StlMesh_SequenceOfMeshTriangle& aTriangles = theMesh->Triangles();
|
||||
for (Standard_Integer aTrgIdx = 1; aTrgIdx <= aTriangles.Length(); ++aTrgIdx)
|
||||
{
|
||||
myTriangleIdxs.Add (aTrgIdx);
|
||||
const Handle(StlMesh_MeshTriangle)& aTriangle = aTriangles.Value (aTrgIdx);
|
||||
Standard_Integer aNodeIdxs[3];
|
||||
Standard_Real aNormalX, aNormalY, aNormalZ;
|
||||
aTriangle->GetVertexAndOrientation (aNodeIdxs[0], aNodeIdxs[1], aNodeIdxs[2], aNormalX, aNormalY, aNormalZ);
|
||||
myTriangles.ChangeValue (aTrgIdx) = Poly_Triangle (aNodeIdxs[0], aNodeIdxs[1], aNodeIdxs[2]);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetGeom
|
||||
// purpose : Returns full info about the entity according to the index and type of element given
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_LODDataSource::GetGeom (const Standard_Integer theId,
|
||||
const Standard_Boolean theIsElement,
|
||||
TColStd_Array1OfReal& theCoords,
|
||||
Standard_Integer& theNodesNb,
|
||||
MeshVS_EntityType& theEntityType) const
|
||||
{
|
||||
if (theId < 1)
|
||||
return Standard_False;
|
||||
|
||||
if (theIsElement)
|
||||
{
|
||||
if (theId > myTriangleIdxs.Extent() || theCoords.Length() < 9)
|
||||
return Standard_False;
|
||||
|
||||
Standard_Integer aNode1, aNode2, aNode3;
|
||||
myTriangles.Value (theId).Get (aNode1, aNode2, aNode3);
|
||||
gp_Pnt aPnts[3] = { myNodes.Value (aNode1),
|
||||
myNodes.Value (aNode2),
|
||||
myNodes.Value (aNode3) };
|
||||
for (Standard_Integer aPntIdx = 0, anIdx = 1; aPntIdx < 3; ++aPntIdx)
|
||||
{
|
||||
for (Standard_Integer aCoordIdx = 0; aCoordIdx < 3; aCoordIdx++)
|
||||
{
|
||||
theCoords (anIdx++) = aPnts[aPntIdx].XYZ().GetData()[aCoordIdx];
|
||||
}
|
||||
}
|
||||
|
||||
theNodesNb = 3;
|
||||
theEntityType = MeshVS_ET_Face;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (theId > myNodeIdxs.Extent() || theCoords.Length() < 3)
|
||||
return Standard_False;
|
||||
|
||||
const gp_Pnt& aNode = myNodes.Value (theId);
|
||||
theCoords (1) = aNode.X();
|
||||
theCoords (2) = aNode.Y();
|
||||
theCoords (3) = aNode.Z();
|
||||
|
||||
theNodesNb = 1;
|
||||
theEntityType = MeshVS_ET_Node;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetGeomType
|
||||
// purpose : Returns type of geometry according to the index and type of element given
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_LODDataSource::GetGeomType (const Standard_Integer /*theId*/,
|
||||
const Standard_Boolean theIsElement,
|
||||
MeshVS_EntityType& theEntityType) const
|
||||
{
|
||||
theEntityType = theIsElement ? MeshVS_ET_Face : MeshVS_ET_Node;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetAddr
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Address MeshVS_LODDataSource::GetAddr (const Standard_Integer /*theId*/,
|
||||
const Standard_Boolean /*theIsElement*/) const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetNodesByElement
|
||||
// purpose : Returns nodes forming a triangle with id theId
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_LODDataSource::GetNodesByElement (const Standard_Integer theId,
|
||||
TColStd_Array1OfInteger& theNodeIds,
|
||||
Standard_Integer& theNodesNb) const
|
||||
{
|
||||
if (theId < 1 || theId > myTriangleIdxs.Extent() || theNodeIds.Length() < 3)
|
||||
return Standard_False;
|
||||
|
||||
const Standard_Integer aLowerIdx = theNodeIds.Lower();
|
||||
myTriangles.Value (theId).Get (theNodeIds.ChangeValue (aLowerIdx),
|
||||
theNodeIds.ChangeValue (aLowerIdx + 1),
|
||||
theNodeIds.ChangeValue (aLowerIdx + 2));
|
||||
theNodesNb = 3;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetAllNodes
|
||||
// purpose : This method makes storing usless map excusable
|
||||
//=======================================================================
|
||||
const TColStd_PackedMapOfInteger& MeshVS_LODDataSource::GetAllNodes() const
|
||||
{
|
||||
return myNodeIdxs;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetAllElements
|
||||
// purpose : This method makes storing usless map excusable
|
||||
//=======================================================================
|
||||
const TColStd_PackedMapOfInteger& MeshVS_LODDataSource::GetAllElements() const
|
||||
{
|
||||
return myTriangleIdxs;
|
||||
}
|
90
src/MeshVS/MeshVS_LODDataSource.hxx
Normal file
90
src/MeshVS/MeshVS_LODDataSource.hxx
Normal file
@@ -0,0 +1,90 @@
|
||||
// Created on: 2015-10-23
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _MeshVS_LODDataSource_Header
|
||||
#define _MeshVS_LODDataSource_Header
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <MeshVS_DataSource.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <Poly_Triangle.hxx>
|
||||
#include <StlMesh_Mesh.hxx>
|
||||
|
||||
//! The class is used to parse LOD data stored in StlMesh_Mesh object
|
||||
class MeshVS_LODDataSource : public MeshVS_DataSource
|
||||
{
|
||||
public:
|
||||
|
||||
Standard_EXPORT MeshVS_LODDataSource (const Handle(StlMesh_Mesh)& theMesh);
|
||||
|
||||
Standard_EXPORT virtual ~MeshVS_LODDataSource() {};
|
||||
|
||||
//! Returns geometry information about node or element
|
||||
//! ID is the numerical identificator of node or element
|
||||
//! IsElement indicates this ID describe node ( if Standard_False ) or element ( if Standard_True )
|
||||
//! Coords is an array of co-ordinates of node(s).
|
||||
//! For node it is only 3 numbers: X, Y, Z in the strict order
|
||||
//! For element it is 3*n numbers, where n is number of this element vertices
|
||||
//! The order is strict also: X1, Y1, Z1, X2,...., where Xi, Yi, Zi are co-ordinates of vertices
|
||||
//! NbNodes is number of nodes. It is recommended this parameter to be set to 1 for node.
|
||||
//! Type is type of node or element (from enumeration). It is recommended this parameter to be set to
|
||||
//! MeshVS_ET_Node for node.
|
||||
Standard_EXPORT virtual Standard_Boolean GetGeom (const Standard_Integer theId,
|
||||
const Standard_Boolean theIsElement,
|
||||
TColStd_Array1OfReal& theCoords,
|
||||
Standard_Integer& theNodesNb,
|
||||
MeshVS_EntityType& theEntityType) const Standard_OVERRIDE;
|
||||
|
||||
//! This method is similar to GetGeom, but returns only element or node type.
|
||||
Standard_EXPORT virtual Standard_Boolean GetGeomType (const Standard_Integer theId,
|
||||
const Standard_Boolean theIsElement,
|
||||
MeshVS_EntityType& theEntityType) const Standard_OVERRIDE;
|
||||
|
||||
//! This method returns pointer which represents element or node data structure.
|
||||
//! This address will be saved in MeshVS_MeshEntityOwner, so that you can access to data structure fast
|
||||
//! by the method Owner(). In the redefined method you can return NULL.
|
||||
//! ID is the numerical identificator of node or element
|
||||
//! IsElement indicates this ID describe node ( if Standard_False ) or element ( if Standard_True )
|
||||
Standard_EXPORT virtual Standard_Address GetAddr (const Standard_Integer theId,
|
||||
const Standard_Boolean theIsElement) const Standard_OVERRIDE;
|
||||
|
||||
//! This method returns information about nodes this element consist of.
|
||||
//! ID is the numerical identificator of element.
|
||||
//! NodeIDs is the output array of nodes IDs in correct order,
|
||||
//! the same as coordinates returned by GetGeom().
|
||||
//! NbNodes is number of nodes (number of items set in NodeIDs).
|
||||
//! Returns False if element does not exist
|
||||
Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer theId,
|
||||
TColStd_Array1OfInteger& theNodeIds,
|
||||
Standard_Integer& theNodesNb) const Standard_OVERRIDE;
|
||||
|
||||
//! This method returns map of all nodes the object consist of.
|
||||
Standard_EXPORT virtual const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE;
|
||||
|
||||
//! This method returns map of all elements the object consist of.
|
||||
Standard_EXPORT virtual const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT (MeshVS_LODDataSource, MeshVS_DataSource)
|
||||
|
||||
private:
|
||||
TColStd_PackedMapOfInteger myNodeIdxs;
|
||||
TColStd_PackedMapOfInteger myTriangleIdxs;
|
||||
TColgp_Array1OfPnt myNodes;
|
||||
Poly_Array1OfTriangle myTriangles;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (MeshVS_LODDataSource, MeshVS_DataSource)
|
||||
|
||||
#endif // _MeshVS_LODDataSource_Header
|
@@ -28,6 +28,7 @@
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_DummySensitiveEntity.hxx>
|
||||
#include <MeshVS_LODBuilder.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_MeshEntityOwner.hxx>
|
||||
#include <MeshVS_MeshOwner.hxx>
|
||||
@@ -137,6 +138,51 @@ MeshVS_Mesh::MeshVS_Mesh (const Standard_Boolean theIsAllowOverlapped )
|
||||
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)
|
||||
{
|
||||
TColStd_PackedMapOfInteger aDummy;
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Compute
|
||||
// Purpose :
|
||||
@@ -171,9 +217,14 @@ void MeshVS_Mesh::Compute ( const Handle(PrsMgr_PresentationManager3d)& thePrsMg
|
||||
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 );
|
||||
if (!Handle(MeshVS_LODBuilder)::DownCast (aCurrent).IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( !aCurrent.IsNull() && aCurrent->TestFlags ( theMode ) )
|
||||
{
|
||||
aCurrent->SetPresentationManager( thePrsMgr );
|
||||
@@ -183,7 +234,7 @@ void MeshVS_Mesh::Compute ( const Handle(PrsMgr_PresentationManager3d)& thePrsMg
|
||||
aCurrent->Build ( thePresentation, aElems, aElemsToExclude, Standard_True, theMode );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ShowComputeTime )
|
||||
{
|
||||
@@ -909,6 +960,15 @@ void MeshVS_Mesh::SetDataSource( const Handle(MeshVS_DataSource)& theDataSource
|
||||
myDataSource = theDataSource;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : AddDataSource
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_Mesh::AddDataSource (const Handle(MeshVS_DataSource)& theDataSource)
|
||||
{
|
||||
myLODDataSources.Append (theDataSource);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : HilightSelected
|
||||
// Purpose :
|
||||
|
@@ -121,7 +121,10 @@ public:
|
||||
|
||||
//! Sets default builders' data source
|
||||
Standard_EXPORT void SetDataSource (const Handle(MeshVS_DataSource)& aDataSource);
|
||||
|
||||
|
||||
//! Adds data source to define LOD
|
||||
Standard_EXPORT void AddDataSource (const Handle(MeshVS_DataSource)& theDataSource);
|
||||
|
||||
//! Returns default builders' drawer
|
||||
Standard_EXPORT Handle(MeshVS_Drawer) GetDrawer() const;
|
||||
|
||||
@@ -178,6 +181,8 @@ public:
|
||||
//! 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;
|
||||
|
||||
|
||||
@@ -185,6 +190,10 @@ 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
|
||||
@@ -209,10 +218,8 @@ protected:
|
||||
Handle(MeshVS_Drawer) myHilightDrawer;
|
||||
Handle(SelectMgr_EntityOwner) myWholeMeshOwner;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
MeshVS_SequenceOfPrsBuilder myBuilders;
|
||||
Handle(MeshVS_PrsBuilder) myHilighter;
|
||||
Handle(TColStd_HPackedMapOfInteger) myHiddenElements;
|
||||
@@ -220,14 +227,7 @@ private:
|
||||
Handle(TColStd_HPackedMapOfInteger) mySelectableNodes;
|
||||
Handle(MeshVS_DataSource) myDataSource;
|
||||
MeshVS_MeshSelectionMethod mySelectionMethod;
|
||||
|
||||
|
||||
NCollection_Vector<Handle(MeshVS_DataSource)> myLODDataSources;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _MeshVS_Mesh_HeaderFile
|
||||
|
@@ -44,64 +44,105 @@ DEFINE_STANDARD_HANDLE(MeshVS_MeshPrsBuilder, MeshVS_PrsBuilder)
|
||||
//! This class provides methods to compute base mesh presentation
|
||||
class MeshVS_MeshPrsBuilder : public MeshVS_PrsBuilder
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//! Creates builder with certain display mode flags, data source, ID and priority
|
||||
Standard_EXPORT MeshVS_MeshPrsBuilder(const Handle(MeshVS_Mesh)& Parent, const MeshVS_DisplayModeFlags& Flags = MeshVS_DMF_OCCMask, const Handle(MeshVS_DataSource)& DS = 0, const Standard_Integer Id = -1, const MeshVS_BuilderPriority& Priority = MeshVS_BP_Mesh);
|
||||
|
||||
Standard_EXPORT MeshVS_MeshPrsBuilder(const Handle(MeshVS_Mesh)& Parent,
|
||||
const MeshVS_DisplayModeFlags& Flags = MeshVS_DMF_OCCMask,
|
||||
const Handle(MeshVS_DataSource)& DS = 0,
|
||||
const Standard_Integer Id = -1,
|
||||
const MeshVS_BuilderPriority& Priority = MeshVS_BP_Mesh);
|
||||
|
||||
//! Builds base mesh presentation by calling the methods below
|
||||
Standard_EXPORT virtual void Build (const Handle(Prs3d_Presentation)& Prs, const TColStd_PackedMapOfInteger& IDs, TColStd_PackedMapOfInteger& IDsToExclude, const Standard_Boolean IsElement, const Standard_Integer DisplayMode) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void Build (const Handle(Prs3d_Presentation)& Prs,
|
||||
const TColStd_PackedMapOfInteger& IDs,
|
||||
TColStd_PackedMapOfInteger& IDsToExclude,
|
||||
const Standard_Boolean IsElement,
|
||||
const Standard_Integer DisplayMode) const Standard_OVERRIDE;
|
||||
|
||||
//! Builds nodes presentation
|
||||
Standard_EXPORT virtual void BuildNodes (const Handle(Prs3d_Presentation)& Prs, const TColStd_PackedMapOfInteger& IDs, TColStd_PackedMapOfInteger& IDsToExclude, const Standard_Integer DisplayMode) const;
|
||||
|
||||
Standard_EXPORT virtual void BuildNodes (const Handle(Prs3d_Presentation)& Prs,
|
||||
const TColStd_PackedMapOfInteger& IDs,
|
||||
TColStd_PackedMapOfInteger& IDsToExclude,
|
||||
const Standard_Integer DisplayMode) const;
|
||||
|
||||
//! Builds elements presentation
|
||||
Standard_EXPORT virtual void BuildElements (const Handle(Prs3d_Presentation)& Prs, const TColStd_PackedMapOfInteger& IDs, TColStd_PackedMapOfInteger& IDsToExclude, const Standard_Integer DisplayMode) const;
|
||||
|
||||
Standard_EXPORT virtual void BuildElements (const Handle(Prs3d_Presentation)& Prs,
|
||||
const TColStd_PackedMapOfInteger& IDs,
|
||||
TColStd_PackedMapOfInteger& IDsToExclude,
|
||||
const Standard_Integer DisplayMode) const;
|
||||
|
||||
//! Builds presentation of hilighted entity
|
||||
Standard_EXPORT virtual void BuildHilightPrs (const Handle(Prs3d_Presentation)& Prs, const TColStd_PackedMapOfInteger& IDs, const Standard_Boolean IsElement) const;
|
||||
|
||||
Standard_EXPORT virtual void BuildHilightPrs (const Handle(Prs3d_Presentation)& Prs,
|
||||
const TColStd_PackedMapOfInteger& IDs,
|
||||
const Standard_Boolean IsElement) const;
|
||||
|
||||
//! Add to array polygons or polylines representing volume
|
||||
Standard_EXPORT static void AddVolumePrs (const Handle(MeshVS_HArray1OfSequenceOfInteger)& Topo, const TColStd_Array1OfReal& Nodes, const Standard_Integer NbNodes, const Handle(Graphic3d_ArrayOfPrimitives)& Array, const Standard_Boolean IsReflected, const Standard_Boolean IsShrinked, const Standard_Boolean IsSelect, const Standard_Real ShrinkCoef);
|
||||
|
||||
Standard_EXPORT static void AddVolumePrs (const Handle(MeshVS_HArray1OfSequenceOfInteger)& Topo,
|
||||
const TColStd_Array1OfReal& Nodes,
|
||||
const Standard_Integer NbNodes,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& Array,
|
||||
const Standard_Boolean IsReflected,
|
||||
const Standard_Boolean IsShrinked,
|
||||
const Standard_Boolean IsSelect,
|
||||
const Standard_Real ShrinkCoef);
|
||||
|
||||
//! Calculate how many polygons or polylines are necessary to draw passed topology
|
||||
Standard_EXPORT static void HowManyPrimitives (const Handle(MeshVS_HArray1OfSequenceOfInteger)& Topo, const Standard_Boolean AsPolygons, const Standard_Boolean IsSelect, const Standard_Integer NbNodes, Standard_Integer& Vertices, Standard_Integer& Bounds);
|
||||
|
||||
|
||||
|
||||
Standard_EXPORT static void HowManyPrimitives (const Handle(MeshVS_HArray1OfSequenceOfInteger)& Topo,
|
||||
const Standard_Boolean AsPolygons,
|
||||
const Standard_Boolean IsSelect,
|
||||
const Standard_Integer NbNodes,
|
||||
Standard_Integer& Vertices,
|
||||
Standard_Integer& Bounds);
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(MeshVS_MeshPrsBuilder,MeshVS_PrsBuilder)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
//! Add to array of polylines some lines representing link
|
||||
Standard_EXPORT void AddLinkPrs (const TColStd_Array1OfReal& theCoords, const Handle(Graphic3d_ArrayOfSegments)& theLines, const Standard_Boolean IsShrinked, const Standard_Real ShrinkCoef) const;
|
||||
|
||||
Standard_EXPORT void AddLinkPrs (const TColStd_Array1OfReal& theCoords,
|
||||
const Handle(Graphic3d_ArrayOfSegments)& theLines,
|
||||
const Standard_Boolean IsShrinked,
|
||||
const Standard_Real ShrinkCoef) const;
|
||||
|
||||
//! Add to array of segments representing face's wire
|
||||
Standard_EXPORT void AddFaceWirePrs (const TColStd_Array1OfReal& theCoords, const Standard_Integer theNbNodes, const Handle(Graphic3d_ArrayOfSegments)& theLines, const Standard_Boolean theIsShrinked, const Standard_Real theShrinkingCoef) const;
|
||||
|
||||
Standard_EXPORT void AddFaceWirePrs (const TColStd_Array1OfReal& theCoords,
|
||||
const Standard_Integer theNbNodes,
|
||||
const Handle(Graphic3d_ArrayOfSegments)& theLines,
|
||||
const Standard_Boolean theIsShrinked,
|
||||
const Standard_Real theShrinkingCoef) const;
|
||||
|
||||
//! Add to array of polygons a polygon representing face
|
||||
Standard_EXPORT void AddFaceSolidPrs (const Standard_Integer ID, const TColStd_Array1OfReal& theCoords, const Standard_Integer theNbNodes, const Standard_Integer theMaxNodes, const Handle(Graphic3d_ArrayOfTriangles)& theTriangles, const Standard_Boolean theIsReflected, const Standard_Boolean theIsShrinked, const Standard_Real theShrinkCoef, const Standard_Boolean theIsMeshSmoothShading) const;
|
||||
|
||||
Standard_EXPORT void AddFaceSolidPrs (const Standard_Integer ID,
|
||||
const TColStd_Array1OfReal& theCoords,
|
||||
const Standard_Integer theNbNodes,
|
||||
const Standard_Integer theMaxNodes,
|
||||
const Handle(Graphic3d_ArrayOfTriangles)& theTriangles,
|
||||
const Standard_Boolean theIsReflected,
|
||||
const Standard_Boolean theIsShrinked,
|
||||
const Standard_Real theShrinkCoef,
|
||||
const Standard_Boolean theIsMeshSmoothShading) const;
|
||||
|
||||
//! Draw array of polygons and polylines in the certain order according to transparency
|
||||
Standard_EXPORT void DrawArrays (const Handle(Prs3d_Presentation)& Prs, const Handle(Graphic3d_ArrayOfPrimitives)& thePolygons, const Handle(Graphic3d_ArrayOfPrimitives)& theLines, const Handle(Graphic3d_ArrayOfPrimitives)& theLinkLines, const Handle(Graphic3d_ArrayOfPrimitives)& theVolumesInShad, const Standard_Boolean IsPolygonsEdgesOff, const Standard_Boolean IsSelected, const Handle(Graphic3d_AspectFillArea3d)& theFillAsp, const Handle(Graphic3d_AspectLine3d)& theLineAsp) const;
|
||||
|
||||
Standard_EXPORT virtual void DrawArrays (const Handle(Prs3d_Presentation)& Prs,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& thePolygons,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& theLines,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& theLinkLines,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& theVolumesInShad,
|
||||
const Standard_Boolean IsPolygonsEdgesOff,
|
||||
const Standard_Boolean IsSelected,
|
||||
const Handle(Graphic3d_AspectFillArea3d)& theFillAsp,
|
||||
const Handle(Graphic3d_AspectLine3d)& theLineAsp) const;
|
||||
|
||||
//! Default calculation of center of face or link. This method if useful for shrink mode presentation
|
||||
//! theCoords is array of nodes co-ordinates in the strict order X1, Y1, Z1, X2...
|
||||
//! NbNodes is number of nodes an element consist of
|
||||
//! xG, yG, zG are co-ordinates of center whose will be returned
|
||||
Standard_EXPORT static void CalculateCenter (const TColStd_Array1OfReal& theCoords, const Standard_Integer NbNodes, Standard_Real& xG, Standard_Real& yG, Standard_Real& zG);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
Standard_EXPORT static void CalculateCenter (const TColStd_Array1OfReal& theCoords,
|
||||
const Standard_Integer NbNodes,
|
||||
Standard_Real& xG,
|
||||
Standard_Real& yG,
|
||||
Standard_Real& zG);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -107,6 +107,10 @@ OpenGl_GlCore44.hxx
|
||||
OpenGl_LayerList.cxx
|
||||
OpenGl_LayerList.hxx
|
||||
OpenGl_LayerFilter.hxx
|
||||
OpenGl_LOD.hxx
|
||||
OpenGl_LOD.cxx
|
||||
OpenGl_LODManager.hxx
|
||||
OpenGl_LODManager.cxx
|
||||
OpenGl_GraphicDriver.cxx
|
||||
OpenGl_GraphicDriver.hxx
|
||||
OpenGl_IndexBuffer.cxx
|
||||
|
41
src/OpenGl/OpenGl_LOD.cxx
Normal file
41
src/OpenGl/OpenGl_LOD.cxx
Normal file
@@ -0,0 +1,41 @@
|
||||
// Created on: 2015-10-29
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <OpenGl_LOD.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (OpenGl_LOD, Graphic3d_LOD)
|
||||
|
||||
//=======================================================================
|
||||
// function : NewGroup
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_Group) OpenGl_LOD::NewGroup (const Handle(Graphic3d_Structure)& theParentStruct)
|
||||
{
|
||||
Handle(OpenGl_Group) aGroup = new OpenGl_Group (theParentStruct);
|
||||
myGroups.Append (aGroup);
|
||||
return aGroup;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : ReleaseGraphicResources
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_LOD::ReleaseGraphicResources (const Handle(OpenGl_Context)& theGlCtx)
|
||||
{
|
||||
for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
aGroupIter.ChangeValue()->Release (theGlCtx);
|
||||
}
|
||||
}
|
45
src/OpenGl/OpenGl_LOD.hxx
Normal file
45
src/OpenGl/OpenGl_LOD.hxx
Normal file
@@ -0,0 +1,45 @@
|
||||
// Created on: 2015-10-29
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _OpenGl_LOD_Header
|
||||
#define _OpenGl_LOD_Header
|
||||
|
||||
#include <Graphic3d_LOD.hxx>
|
||||
#include <OpenGl_AspectFace.hxx>
|
||||
#include <OpenGl_AspectLine.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
|
||||
//! This class provides an implementation of TKOpenGl-dependent LOD
|
||||
//! functionality, such as creation of new graphic groups and cleaning
|
||||
//! up graphic resources
|
||||
class OpenGl_LOD : public Graphic3d_LOD
|
||||
{
|
||||
public:
|
||||
|
||||
Standard_EXPORT OpenGl_LOD() : Graphic3d_LOD () {};
|
||||
Standard_EXPORT ~OpenGl_LOD() {};
|
||||
|
||||
//! Creates new graphic group for LOD rendering and adds it to the map
|
||||
Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theParentStruct) Standard_OVERRIDE;
|
||||
|
||||
//! Releases graphic resources of each created graphic group
|
||||
void ReleaseGraphicResources (const Handle(OpenGl_Context)& theGlCtx);
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT (OpenGl_LOD, Graphic3d_LOD)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (OpenGl_LOD, Graphic3d_LOD)
|
||||
|
||||
#endif // _OpenGl_LOD_Header
|
86
src/OpenGl/OpenGl_LODManager.cxx
Normal file
86
src/OpenGl/OpenGl_LODManager.cxx
Normal file
@@ -0,0 +1,86 @@
|
||||
// Created on: 2015-11-25
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_LOD.hxx>
|
||||
#include <OpenGl_LOD.hxx>
|
||||
#include <OpenGl_LODManager.hxx>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (OpenGl_LODManager, Graphic3d_LODManager)
|
||||
|
||||
namespace
|
||||
{
|
||||
// Comparison operator for sorting LODs
|
||||
class CompareLODS
|
||||
{
|
||||
public:
|
||||
|
||||
CompareLODS (const Graphic3d_MapOfLODs& theLODs)
|
||||
: myLODs (theLODs) {}
|
||||
|
||||
Standard_Boolean operator() (const Standard_Integer theLeftIdx, const Standard_Integer theRightIdx) const
|
||||
{
|
||||
return myLODs.FindKey (theLeftIdx)->GetRange() < myLODs.FindKey (theRightIdx)->GetRange();
|
||||
}
|
||||
|
||||
private:
|
||||
void operator = (const CompareLODS&);
|
||||
|
||||
private:
|
||||
const Graphic3d_MapOfLODs& myLODs;
|
||||
};
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Creation
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
OpenGl_LODManager::OpenGl_LODManager (const Handle(Graphic3d_Structure)& theParentStructure)
|
||||
: Graphic3d_LODManager (theParentStructure)
|
||||
{
|
||||
Standard_ASSERT_RAISE (!theParentStructure.IsNull(),
|
||||
"Parent structure of LOD manager is null!");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : AddNewLOD
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_LOD) OpenGl_LODManager::AddNewLOD()
|
||||
{
|
||||
Handle(Graphic3d_LOD) aNewLOD = new OpenGl_LOD();
|
||||
myLODs.Add (aNewLOD);
|
||||
myIsToSortLODs = Standard_True;
|
||||
return aNewLOD;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : sortLODs
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_LODManager::sortLODs()
|
||||
{
|
||||
Standard_Integer anIndArrSize = myLODs.Extent();
|
||||
myLODIndexes.Nullify();
|
||||
myLODIndexes = new TColStd_HArray1OfInteger (0, anIndArrSize - 1);
|
||||
for (Standard_Integer anIdx = 0; anIdx < anIndArrSize; ++anIdx)
|
||||
{
|
||||
myLODIndexes->SetValue (anIdx, anIdx + 1);
|
||||
}
|
||||
TColStd_Array1OfInteger& anIdxArr = myLODIndexes->ChangeArray1();
|
||||
std::sort (anIdxArr.begin(), anIdxArr.end(), CompareLODS (myLODs));
|
||||
myIsToSortLODs = Standard_False;
|
||||
}
|
48
src/OpenGl/OpenGl_LODManager.hxx
Normal file
48
src/OpenGl/OpenGl_LODManager.hxx
Normal file
@@ -0,0 +1,48 @@
|
||||
// Created on: 2015-11-25
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _OpenGl_LODManager_Header
|
||||
#define _OpenGl_LODManager_Header
|
||||
|
||||
#include <Graphic3d_LODManager.hxx>
|
||||
|
||||
//! This class provides an API for LOD manager to TKOpenGl
|
||||
//! structures, such as OpenGl_Structure. It also implements
|
||||
//! the TKOpenGl-dependent functionality of LOD manager, for
|
||||
//! example, creation of a new LOD.
|
||||
class OpenGl_LODManager : public Graphic3d_LODManager
|
||||
{
|
||||
public:
|
||||
|
||||
//! Creates new empty manager and checks the parent structure pointer for validity
|
||||
Standard_EXPORT OpenGl_LODManager (const Handle(Graphic3d_Structure)& theParentStructure);
|
||||
|
||||
Standard_EXPORT virtual ~OpenGl_LODManager() {};
|
||||
|
||||
//! Creates new LOD without any graphic groups and marks map of LODs for sorting
|
||||
Standard_EXPORT virtual Handle(Graphic3d_LOD) AddNewLOD() Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT (OpenGl_LODManager, Graphic3d_LODManager)
|
||||
|
||||
protected:
|
||||
|
||||
//! Sorts added LODs according to its ranges in order to speed up
|
||||
//! the process of picking the LOD to display
|
||||
Standard_EXPORT virtual void sortLODs() Standard_OVERRIDE;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (OpenGl_LODManager, Graphic3d_LODManager)
|
||||
|
||||
#endif // _OpenGl_LODManager_Header
|
@@ -17,6 +17,8 @@
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_GraphicDriver.hxx>
|
||||
#include <OpenGl_LOD.hxx>
|
||||
#include <OpenGl_LODManager.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
#include <OpenGl_ShaderProgram.hxx>
|
||||
#include <OpenGl_StructureShadow.hxx>
|
||||
@@ -25,6 +27,7 @@
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
#include <Graphic3d_SequenceOfHClipPlane.hxx>
|
||||
#include <Graphic3d_LODManager.hxx>
|
||||
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Structure,Graphic3d_CStructure)
|
||||
@@ -424,6 +427,19 @@ Handle(Graphic3d_Group) OpenGl_Structure::NewGroup (const Handle(Graphic3d_Struc
|
||||
return aGroup;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : NewLOD
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Graphic3d_LOD) OpenGl_Structure::NewLOD (const Handle(Graphic3d_Structure)& theStruct)
|
||||
{
|
||||
if (myLODManager.IsNull())
|
||||
{
|
||||
myLODManager = new OpenGl_LODManager (theStruct);
|
||||
}
|
||||
return myLODManager->AddNewLOD();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : RemoveGroup
|
||||
// purpose :
|
||||
@@ -504,7 +520,8 @@ void OpenGl_Structure::renderGeometry (const Handle(OpenGl_Workspace)& theWorksp
|
||||
myInstancedStructure->renderGeometry (theWorkspace, theHasClosed);
|
||||
}
|
||||
|
||||
for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
|
||||
const Graphic3d_SequenceOfGroup& aGroups = DrawGroups();
|
||||
for (OpenGl_Structure::GroupIterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
theHasClosed = theHasClosed || aGroupIter.Value()->IsClosed();
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
@@ -543,6 +560,9 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
|
||||
return;
|
||||
}
|
||||
|
||||
if (!myLODManager.IsNull() && !myLODManager->HasLODToDisplay (theWorkspace->View()->Camera()))
|
||||
return;
|
||||
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
|
||||
// Render named status
|
||||
@@ -733,6 +753,14 @@ void OpenGl_Structure::ReleaseGlResources (const Handle(OpenGl_Context)& theGlCt
|
||||
{
|
||||
aGroupIter.ChangeValue()->Release (theGlCtx);
|
||||
}
|
||||
if (!myLODManager.IsNull())
|
||||
{
|
||||
for (Standard_Integer aLODIdx = 1; aLODIdx <= myLODManager->NbOfDetailLevels(); ++aLODIdx)
|
||||
{
|
||||
Handle(OpenGl_LOD) aLOD = Handle(OpenGl_LOD)::DownCast (myLODManager->GetLODById (aLODIdx));
|
||||
aLOD->ReleaseGraphicResources (theGlCtx);
|
||||
}
|
||||
}
|
||||
if (myAspectLine != NULL)
|
||||
{
|
||||
myAspectLine->Release (theGlCtx.operator->());
|
||||
@@ -763,3 +791,52 @@ Handle(Graphic3d_CStructure) OpenGl_Structure::ShadowLink (const Handle(Graphic3
|
||||
{
|
||||
return new OpenGl_StructureShadow (theManager, this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDetailLevelRange
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_Structure::SetDetailLevelRange (const Standard_Integer theLODIdx,
|
||||
const Standard_Real theFrom,
|
||||
const Standard_Real theTo)
|
||||
{
|
||||
Standard_ASSERT_RAISE (theFrom < theTo,
|
||||
"The upper boundary of the interval must be greater than lower one!");
|
||||
|
||||
if (myLODManager.IsNull() || theLODIdx < 1 || theLODIdx > myLODManager->NbOfDetailLevels())
|
||||
return;
|
||||
|
||||
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 :
|
||||
//=======================================================================
|
||||
const Graphic3d_SequenceOfGroup& OpenGl_Structure::DrawGroups() const
|
||||
{
|
||||
return myLODManager.IsNull() ? myGroups : myLODManager->GetCurrentGroups();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbDetailLevels
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer OpenGl_Structure::NbDetailLevels() const
|
||||
{
|
||||
return myLODManager->NbOfDetailLevels();
|
||||
}
|
||||
|
@@ -35,8 +35,10 @@
|
||||
|
||||
class OpenGl_Structure;
|
||||
class OpenGl_GraphicDriver;
|
||||
class OpenGl_LOD;
|
||||
|
||||
typedef NCollection_List<const OpenGl_Structure* > OpenGl_ListOfStructure;
|
||||
typedef NCollection_Vector<Handle(OpenGl_LOD)> OpenGl_VectorOfLODs;
|
||||
|
||||
//! Implementation of low-level graphic structure.
|
||||
class OpenGl_Structure : public Graphic3d_CStructure
|
||||
@@ -98,16 +100,32 @@ public:
|
||||
//! Create new group within this structure
|
||||
Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE;
|
||||
|
||||
//! Create new LOD within this structure
|
||||
Standard_EXPORT virtual Handle(Graphic3d_LOD) NewLOD (const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE;
|
||||
|
||||
//! 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
|
||||
virtual const Graphic3d_SequenceOfGroup& DrawGroups() const
|
||||
{
|
||||
return myGroups;
|
||||
}
|
||||
virtual const Graphic3d_SequenceOfGroup& DrawGroups() const;
|
||||
|
||||
//! Access graphic driver
|
||||
OpenGl_GraphicDriver* GlDriver() const
|
||||
@@ -197,6 +215,8 @@ public:
|
||||
//! Is the structure ray-tracable (contains ray-tracable elements)?
|
||||
Standard_Boolean IsRaytracable() const;
|
||||
|
||||
Standard_EXPORT virtual Standard_Integer NbDetailLevels() const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT virtual ~OpenGl_Structure();
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
class Graphic3d_Group;
|
||||
class Graphic3d_LOD;
|
||||
class Prs3d_Presentation;
|
||||
|
||||
|
||||
@@ -44,22 +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);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -71,7 +71,10 @@ void PrsMgr_PresentableObject::Fill (const Handle(PrsMgr_PresentationManager)& t
|
||||
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());
|
||||
@@ -523,3 +526,26 @@ Standard_Boolean PrsMgr_PresentableObject::IsMutable() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@@ -199,6 +199,11 @@ public:
|
||||
//! Returns parent of current object in scene hierarchy.
|
||||
Standard_EXPORT PrsMgr_PresentableObjectPointer Parent() const;
|
||||
|
||||
//! Must be redefined for objects represented through levels of detail.
|
||||
//! Default implementation returns false, if the object is represented by
|
||||
//! LODs, the method must return true.
|
||||
Standard_EXPORT virtual Standard_Boolean HasLevelsOfDetail() const;
|
||||
|
||||
|
||||
friend class PrsMgr_Presentation;
|
||||
friend class PrsMgr_PresentationManager;
|
||||
@@ -219,7 +224,12 @@ protected:
|
||||
|
||||
Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
|
||||
Standard_EXPORT virtual ~PrsMgr_PresentableObject();
|
||||
|
||||
|
||||
//! Computes levels of detail for the presentation.
|
||||
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;
|
||||
|
@@ -4,3 +4,4 @@ TKService
|
||||
TKernel
|
||||
TKG3d
|
||||
TKG2d
|
||||
TKSTL
|
||||
|
@@ -55,6 +55,7 @@
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
#include <ViewerTest.hxx>
|
||||
#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
|
||||
#include <VrmlAPI.hxx>
|
||||
#include <VrmlAPI_Writer.hxx>
|
||||
#include <VrmlData_DataMapOfShapeAppearance.hxx>
|
||||
@@ -80,6 +81,7 @@
|
||||
extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
|
||||
const Handle(AIS_InteractiveObject)& theAISObj,
|
||||
Standard_Boolean theReplaceIfExists = Standard_True);
|
||||
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
|
||||
|
||||
static Standard_Integer writestl
|
||||
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
@@ -1202,6 +1204,352 @@ static Standard_Integer meshinfo(Draw_Interpretor& di,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepMesh_IncrementalMesh.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <MeshVS_LODDataSource.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <ViewerTest_AutoUpdater.hxx>
|
||||
//=======================================================================
|
||||
//function : MeshGenLODs
|
||||
//purpose : Generates sequence of LODs for the shape given
|
||||
//=======================================================================
|
||||
static int MeshGenLODs (Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNum,
|
||||
const char** theArgs)
|
||||
{
|
||||
if (theArgNum < 3)
|
||||
{
|
||||
std::cout << "Error! Wrong number of arguments. See usage:\n";
|
||||
theDI.PrintHelp (theArgs[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
||||
if (aCtx.IsNull())
|
||||
{
|
||||
std::cout << "Error! No opened viewer." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_CString aShapeName = theArgs[1];
|
||||
const TopoDS_Shape aShape = DBRep::Get (aShapeName);
|
||||
if (aShape.IsNull())
|
||||
{
|
||||
std::cout << "Error! No shape with the name " << aShapeName << "." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
const Standard_Integer aLODsNb = Draw::Atoi (theArgs[2]);
|
||||
if (aLODsNb <= 0)
|
||||
{
|
||||
std::cout << "Error! Incorrect amount of LODs passed: " << aLODsNb << "." << std::endl;
|
||||
std::cout << "Must be greater than zero." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
Standard_Boolean toPrintInfo = Standard_False;
|
||||
TCollection_AsciiString aSavePath = "";
|
||||
Handle(MeshVS_Mesh) aMesh = NULL;
|
||||
if (theArgNum > 3)
|
||||
{
|
||||
for (Standard_Integer anArgIdx = 3; anArgIdx < theArgNum; ++anArgIdx)
|
||||
{
|
||||
TCollection_AsciiString anArg (theArgs[anArgIdx]);
|
||||
anArg.LowerCase();
|
||||
if (anArg == "-debug")
|
||||
{
|
||||
toPrintInfo = Standard_True;
|
||||
}
|
||||
else if (anArg == "-mesh")
|
||||
{
|
||||
aMesh = Handle(MeshVS_Mesh)::DownCast (GetMapOfAIS().Find2 (theArgs[++anArgIdx]));
|
||||
}
|
||||
else if (anArg == "-save")
|
||||
{
|
||||
aSavePath = TCollection_AsciiString (theArgs[++anArgIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Determine max deflection of a shape
|
||||
Handle(Poly_Triangulation) aFaceTrg;
|
||||
TopLoc_Location aFaceLoc;
|
||||
Standard_Real aMaxDefl = 0.0;
|
||||
for (TopExp_Explorer anExplorer (aShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next())
|
||||
{
|
||||
TopoDS_Face aCurFace = TopoDS::Face (anExplorer.Current());
|
||||
aFaceTrg = BRep_Tool::Triangulation (aCurFace, aFaceLoc);
|
||||
if (!aFaceTrg.IsNull())
|
||||
{
|
||||
if (aFaceTrg->Deflection() > aMaxDefl)
|
||||
aMaxDefl = aFaceTrg->Deflection();
|
||||
}
|
||||
}
|
||||
|
||||
BRepTools::Clean (aShape);
|
||||
BRepMesh_FastDiscret::Parameters aMeshParams;
|
||||
aMeshParams.Deflection = aMaxDefl;
|
||||
aMeshParams.Angle = 0.5;
|
||||
aMeshParams.Relative = Standard_False;
|
||||
aMeshParams.InParallel = Standard_True;
|
||||
aMeshParams.MinSize = Precision::Confusion();
|
||||
aMeshParams.InternalVerticesMode = Standard_True;
|
||||
aMeshParams.ControlSurfaceDeflection = Standard_True;
|
||||
aMeshParams.AdaptiveMin = Standard_False;
|
||||
BRepMesh_IncrementalMesh aBaseMesher (aShape, aMeshParams);
|
||||
aBaseMesher.Perform();
|
||||
ViewerTest_AutoUpdater anAutoUpd (aCtx, ViewerTest::CurrentView());
|
||||
|
||||
|
||||
// compute the shape for each LOD
|
||||
TopoDS_Shape* aLODShapes = new TopoDS_Shape[aLODsNb];
|
||||
BRepBuilderAPI_Copy aMainCopyAlgo;
|
||||
aMainCopyAlgo.Perform (aShape, Standard_True, Standard_True);
|
||||
aLODShapes[0] = aMainCopyAlgo.Shape();
|
||||
Standard_Real aDeflDecrFactor = aMaxDefl / aLODsNb;
|
||||
for (Standard_Integer aLODIdx = 1; aLODIdx < aLODsNb; ++aLODIdx)
|
||||
{
|
||||
BRepBuilderAPI_Copy aCopyAlgo;
|
||||
aCopyAlgo.Perform (aShape, Standard_True, Standard_True);
|
||||
aLODShapes[aLODIdx] = aCopyAlgo.Shape();
|
||||
BRepTools::Clean (aLODShapes[aLODIdx]);
|
||||
BRepMesh_FastDiscret::Parameters aParams;
|
||||
aParams.Deflection = aMaxDefl - aLODIdx * aDeflDecrFactor;
|
||||
aParams.Angle = 0.5;
|
||||
aParams.Relative = Standard_False;
|
||||
aParams.InParallel = Standard_True;
|
||||
aParams.MinSize = Precision::Confusion();
|
||||
aParams.InternalVerticesMode = Standard_True;
|
||||
aParams.ControlSurfaceDeflection = Standard_True;
|
||||
aParams.AdaptiveMin = Standard_False;
|
||||
BRepMesh_IncrementalMesh aMesher (aLODShapes[aLODIdx], aParams);
|
||||
aMesher.Perform();
|
||||
if (toPrintInfo)
|
||||
{
|
||||
Standard_Integer aStatus = aMesher.GetStatusFlags();
|
||||
std::cout << "LOD #" << aLODIdx << " meshing status: ";
|
||||
if (!aStatus)
|
||||
std::cout << " OK" << std::endl;
|
||||
else
|
||||
{
|
||||
for (Standard_Integer aBitIdx = 0; aBitIdx < 4; ++aBitIdx)
|
||||
{
|
||||
if ((aStatus >> aBitIdx) & 1)
|
||||
{
|
||||
switch (aBitIdx + 1)
|
||||
{
|
||||
case 1:
|
||||
std::cout << " OpenWire ";
|
||||
break;
|
||||
case 2:
|
||||
std::cout << " SelfIntersectingWire ";
|
||||
break;
|
||||
case 3:
|
||||
std::cout << " Failure ";
|
||||
break;
|
||||
case 4:
|
||||
std::cout << " ReMesh ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (toPrintInfo)
|
||||
{
|
||||
std::cout << std::endl;
|
||||
for (Standard_Integer aLODIdx = 0; aLODIdx < aLODsNb; ++aLODIdx)
|
||||
{
|
||||
std::cout << "LOD #" << aLODIdx + 1 << " info:" << std::endl;
|
||||
if (aLODShapes[aLODIdx].IsNull())
|
||||
{
|
||||
std::cout << "The shape is null!" << std::endl;
|
||||
}
|
||||
|
||||
Handle(Poly_Triangulation) aCurTrg;
|
||||
TopLoc_Location aCurLoc;
|
||||
Standard_Real aDefl = 0.0;
|
||||
Standard_Integer aTrgsNb = 0, aNodesNb = 0;
|
||||
for (TopExp_Explorer aShapeExp (aLODShapes[aLODIdx], TopAbs_FACE); aShapeExp.More(); aShapeExp.Next())
|
||||
{
|
||||
TopoDS_Face aCurFace = TopoDS::Face (aShapeExp.Current());
|
||||
aCurTrg = BRep_Tool::Triangulation (aCurFace, aCurLoc);
|
||||
if (!aCurTrg.IsNull())
|
||||
{
|
||||
aTrgsNb += aCurTrg->NbTriangles();
|
||||
aNodesNb += aCurTrg->NbNodes();
|
||||
if (aCurTrg->Deflection() > aDefl)
|
||||
aDefl = aCurTrg->Deflection();
|
||||
}
|
||||
}
|
||||
std::cout << "deflection : " << aDefl << std::endl;
|
||||
std::cout << "triangles nb: " << aTrgsNb << std::endl;
|
||||
std::cout << "nodes nb : " << aNodesNb << std::endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (aSavePath != "")
|
||||
{
|
||||
if (aSavePath.Value (aSavePath.Length()) != '/')
|
||||
{
|
||||
aSavePath = aSavePath + "/";
|
||||
}
|
||||
aSavePath = aSavePath + aShapeName + "_LOD";
|
||||
for (Standard_Integer aLODIdx = 0; aLODIdx < aLODsNb; ++aLODIdx)
|
||||
{
|
||||
StlAPI_Writer aWriter;
|
||||
aWriter.ASCIIMode() = Standard_False;
|
||||
TCollection_AsciiString aPath = aSavePath + aLODIdx + ".stl";
|
||||
StlAPI_ErrorStatus aStatus = aWriter.Write (aLODShapes[aLODIdx], aPath.ToCString());
|
||||
switch (aStatus)
|
||||
{
|
||||
case StlAPI_CannotOpenFile:
|
||||
std::cout << "Error! Cannot create/open a file with the name: " << aPath << std::endl;
|
||||
break;
|
||||
case StlAPI_StatusOK:
|
||||
default:
|
||||
std::cout << "LOD" << aLODIdx << " was written sucessfully to the file " << aPath << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <MeshVS_LODBuilder.hxx>
|
||||
static int MeshLOD (Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNum,
|
||||
const char** theArgs)
|
||||
{
|
||||
struct DetailLevelData
|
||||
{
|
||||
public:
|
||||
DetailLevelData()
|
||||
: myMesh (NULL),
|
||||
myFrom (-DBL_MAX),
|
||||
myTo (DBL_MAX) {}
|
||||
|
||||
public:
|
||||
Handle(StlMesh_Mesh) myMesh;
|
||||
Standard_Real myFrom;
|
||||
Standard_Real myTo;
|
||||
};
|
||||
|
||||
if (theArgNum < 3)
|
||||
{
|
||||
std::cout << "Error! Wrong number of arguments. See usage:\n";
|
||||
theDI.PrintHelp (theArgs[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
||||
if (aCtx.IsNull())
|
||||
{
|
||||
std::cout << "Error! No opened viewer." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_CString aShapeName = theArgs[1];
|
||||
if (GetMapOfAIS().IsBound2 (aShapeName))
|
||||
{
|
||||
std::cout << "Error! The context already has an interactive object with the name " << aShapeName << "." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
const TCollection_AsciiString aPathToLODInfo = Draw::Atoi (theArgs[2]);
|
||||
if (aPathToLODInfo == "")
|
||||
{
|
||||
std::cout << "Error! Path to LOD info must not be empty!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::ifstream aLODInfoFile (theArgs[2]);
|
||||
NCollection_List<DetailLevelData> myLODDataList;
|
||||
Handle(StlMesh_Mesh) aLargestMesh;
|
||||
for (std::string aLODInfoStr; getline (aLODInfoFile, aLODInfoStr);)
|
||||
{
|
||||
DetailLevelData aData;
|
||||
std::istringstream aStream (aLODInfoStr);
|
||||
std::vector<std::string> aTokens;
|
||||
std::copy (std::istream_iterator<std::string> (aStream),
|
||||
std::istream_iterator<std::string>(),
|
||||
std::back_inserter (aTokens));
|
||||
for (Standard_Integer aTokenIdx = 0; aTokenIdx < aTokens.size(); ++aTokenIdx)
|
||||
{
|
||||
if (aTokens[aTokenIdx] == "-path")
|
||||
{
|
||||
OSD_Path aFile (aTokens[++aTokenIdx].c_str());
|
||||
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
|
||||
Handle(StlMesh_Mesh) aSTLMesh = RWStl::ReadFile (aFile, aProgress);
|
||||
if (aSTLMesh.IsNull())
|
||||
{
|
||||
std::cout << "Error! Can not read LOD located at the path: " << aTokens[aTokenIdx] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
aData.myMesh = aSTLMesh;
|
||||
if (aLargestMesh.IsNull() || aSTLMesh->Triangles().Length() > aLargestMesh->Triangles().Length())
|
||||
{
|
||||
aLargestMesh = aSTLMesh;
|
||||
}
|
||||
}
|
||||
else if (aTokens[aTokenIdx] == "-from")
|
||||
{
|
||||
aData.myFrom = Draw::Atof (aTokens[++aTokenIdx].c_str());
|
||||
}
|
||||
else if (aTokens[aTokenIdx] == "-to")
|
||||
{
|
||||
aData.myTo = Draw::Atof (aTokens[++aTokenIdx].c_str());
|
||||
}
|
||||
}
|
||||
myLODDataList.Append (aData);
|
||||
}
|
||||
|
||||
if (aLargestMesh.IsNull())
|
||||
{
|
||||
std::cout << "Error! No meshes found in lod info file!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(MeshVS_Mesh) anOriginMesh = new MeshVS_Mesh();
|
||||
for (NCollection_List<DetailLevelData>::Iterator aLODDataIter (myLODDataList); aLODDataIter.More(); aLODDataIter.Next())
|
||||
{
|
||||
Handle(MeshVS_LODDataSource) aLOD = new MeshVS_LODDataSource (aLODDataIter.Value().myMesh);
|
||||
anOriginMesh->AddDataSource (aLOD);
|
||||
Handle(MeshVS_LODBuilder) aLODBuilder = new MeshVS_LODBuilder (anOriginMesh.operator->());
|
||||
aLODBuilder->SetDataSource (aLOD);
|
||||
aLODBuilder->GetDrawer()->SetColor (MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW);
|
||||
anOriginMesh->AddBuilder (aLODBuilder);
|
||||
}
|
||||
|
||||
// Hide all nodes by default
|
||||
Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
|
||||
Standard_Integer aLen = aLargestMesh->Vertices().Length();
|
||||
for (Standard_Integer anIndex = 1; anIndex <= aLen; ++anIndex)
|
||||
aNodes->ChangeMap().Add (anIndex);
|
||||
anOriginMesh->SetHiddenNodes (aNodes);
|
||||
anOriginMesh->SetSelectableNodes (aNodes);
|
||||
|
||||
VDisplayAISObject (aShapeName, anOriginMesh);
|
||||
aCtx->Deactivate (anOriginMesh);
|
||||
|
||||
Standard_Integer aLODIdx = 1;
|
||||
for (NCollection_List<DetailLevelData>::Iterator aLODDataIter (myLODDataList); aLODDataIter.More(); aLODDataIter.Next())
|
||||
{
|
||||
anOriginMesh->Presentation()->SetDetailLevelRange (aLODIdx, aLODDataIter.Value().myFrom, aLODDataIter.Value().myTo);
|
||||
aLODIdx++;
|
||||
}
|
||||
|
||||
Handle(V3d_View) aView = ViewerTest::CurrentView();
|
||||
if (!aView.IsNull())
|
||||
aView->FitAll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands)
|
||||
@@ -1232,6 +1580,24 @@ void XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands)
|
||||
theCommands.Add ("meshdeform", "display deformed mesh", __FILE__, meshdeform, g );
|
||||
theCommands.Add ("mesh_edge_width", "set width of edges", __FILE__, mesh_edge_width, g );
|
||||
theCommands.Add ("meshinfo", "displays the number of nodes and triangles", __FILE__, meshinfo, g );
|
||||
theCommands.Add ("meshgenlods",
|
||||
"meshgenlods shapeName lodsNb [-save pathToFolder] [-mesh meshName] [-debug]"
|
||||
"\n\t\t: Generates sequence of LODs for the shape with shapeName in amount of lodsNb."
|
||||
"\n\t\t: lodsNb means the exact amount of physical LODs to generate, e.g. the main"
|
||||
"\n\t\t: object's presentation is not considered as a separate level of detail here."
|
||||
"\n\t\t: [-debug] enables printing of meshing status and each LOD's info.",
|
||||
__FILE__, MeshGenLODs, g);
|
||||
theCommands.Add ("meshlod",
|
||||
"meshlod shapeName pathToFileWithLODInfo"
|
||||
"\n\t\t: Creates an object with the name shapeName that has LODs described in file stored at"
|
||||
"\n\t\t: pathToFileWithLODInfo. Each string in the file is a full description of LOD. It must"
|
||||
"\n\t\t: be filled using the following form:"
|
||||
"\n\t\t: -path pathToLOD [-from fromRange] [-to toRange], where"
|
||||
"\n\t\t: pathToLOD is a path to STL file with LOD mesh, fromRange and toRange define a depth"
|
||||
"\n\t\t: range where the LOD will be visible. Each of range parameters is optional, but in this"
|
||||
"\n\t\t: case, it will be equal to positive and negative max double correspondingly."
|
||||
"\n\t\t: It is assumed that ranges are non-overlapping segments of the real axis."
|
||||
__FILE__, MeshLOD, g);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
24
tests/bugs/vis/bug26812
Normal file
24
tests/bugs/vis/bug26812
Normal file
@@ -0,0 +1,24 @@
|
||||
set aPathToData ""
|
||||
set aTmpFolder ""
|
||||
|
||||
pload ALL
|
||||
vinit
|
||||
meshlod m $aTmpFolder/lod_data.txt
|
||||
|
||||
##########################################################################
|
||||
# to generate brep file for LODs generaion, it is requred to use
|
||||
# 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
|
Reference in New Issue
Block a user