Skip to content

Optimization of the display of topological entities during interactio… #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Core/Internal/Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ _allowThreadedFacePreMeshTasks ("allowThreadedFacePreMeshTasks", true, UTF8Strin
_allowThreadedBlockPreMeshTasks ("allowThreadedBlockPreMeshTasks", true, UTF8String ("true si le prémaillage des blocs peut être décomposé en plusieurs tâches exécutées parallèlement dans plusieurs threads, false si l'exécution doit être séquentielle.")),
_displayScriptOutputs ("displayScriptOutputs", true, UTF8String ("true si le programme doit afficher les sorties des commandes script, false dans le cas contraire.")),
_memorizeEdgePreMesh ("memorizeEdgePreMesh", true, UTF8String ("true si le programme doit mémoriser le prémaillage des arêtes, false dans le cas contraire.")),
_lodPointSize ("lodPointSize", 1, UTF8String ("Taille des points/noeuds/vertex lors des interactions.", Charset::UTF_8)),
_lodLineWidth ("lodLineWidth", 1, UTF8String ("Epaisseur des lignes/arêtes lors des interactions.", Charset::UTF_8)),
_fontFamily ("fontFamily", "Arial", UTF8String ("Police de caractères utilisée pour les affichages graphiques. Valeurs possibles : Arial, Times, Courier.", Charset::UTF_8)),
_fontSize ("fontSize", 12, UTF8String ("Taille de la police de caractères utilisée pour les affichages graphiques.", Charset::UTF_8)),
_fontBold ("bold", false, UTF8String ("Caractère gras de la police de caractères utilisée pour les affichages graphiques. Si true la police est grasse.", Charset::UTF_8)),
Expand Down Expand Up @@ -104,7 +106,10 @@ _loadGuiState ("loadGuiState", true, UTF8String ("True si l'état de l'IHM (posi
_geomDestroyOnHide ("destroyOnHide", false, UTF8String ("True si la représentation graphique des entités géométriques doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire.", Charset::UTF_8)),
_topoDestroyOnHide ("destroyOnHide", false, UTF8String ("True si la représentation graphique des entités topologiques doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire.", Charset::UTF_8)),
_meshDestroyOnHide ("destroyOnHide", true, UTF8String ("True si la représentation graphique des entités de maillage doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire.", Charset::UTF_8)),

_topoVertexLodNumberThreshold ("topoVertexLodNumberThreshold", 250, UTF8String ("Nombre maximum de vertex topologiques à afficher lors d'interactions.", Charset::UTF_8)),
_topoEdgeLodNumberThreshold ("topoEdgeLodNumberThreshold", 250, UTF8String ("Nombre maximum d'arêtes topologiques à afficher lors d'interactions.", Charset::UTF_8)),
_topoFaceLodNumberThreshold ("topoFaceLodNumberThreshold", 250, UTF8String ("Nombre maximum de faces topologiques à afficher lors d'interactions.", Charset::UTF_8)),
_topoBlockLodNumberThreshold ("topoBlockLodNumberThreshold", 250, UTF8String ("Nombre maximum de blocs topologiques à afficher lors d'interactions.", Charset::UTF_8)),

_organisation ("CEA.DAM.DSSI"),
_softwareName ("Magix3D"),
Expand All @@ -130,6 +135,8 @@ _allowThreadedFacePreMeshTasks ("allowThreadedFacePreMeshTasks", true, UTF8Strin
_allowThreadedBlockPreMeshTasks ("allowThreadedBlockPreMeshTasks", true, UTF8String ("true si le prémaillage des blocs peut être décomposé en plusieurs tâches exécutées parallèlement dans plusieurs threads, false si l'exécution doit être séquentielle.")),
_displayScriptOutputs ("displayScriptOutputs", true, UTF8String ("true si le programme doit afficher les sorties des commandes script, false dans le cas contraire.")),
_memorizeEdgePreMesh ("memorizeEdgePreMesh", true, UTF8String ("true si le programme doit mémoriser le prémaillage des arêtes, false dans le cas contraire.")),
_lodPointSize ("lodPointSize", 1, UTF8String ("Taille des points/noeuds/vertex lors des interactions.", Charset::UTF_8)),
_lodLineWidth ("lodLineWidth", 1, UTF8String ("Epaisseur des lignes/arêtes lors des interactions.", Charset::UTF_8)),
_fontFamily ("fontFamily", "Arial", "Police de caractères utilisée pour les affichages graphiques. Valeurs possibles : Arial, Times, Courier."),
_fontSize ("fontSize", 12, "Taille de la police de caractères utilisée pour les affichages graphiques."),
_fontBold ("bold", false, "Caractère gras de la police de caractères utilisée pour les affichages graphiques. Si true la police est grasse."),
Expand Down Expand Up @@ -200,7 +207,10 @@ _loadGuiState ("loadGuiState", true, "True si l'état de l'IHM (position, taille
_geomDestroyOnHide ("destroyOnHide", false, "True si la représentation graphique des entités géométriques doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire."),
_topoDestroyOnHide ("destroyOnHide", false, "True si la représentation graphique des entités topologiques doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire."),
_meshDestroyOnHide ("destroyOnHide", true, "True si la représentation graphique des entités de maillage doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire."),

_topoVertexLodNumberThreshold ("topoVertexLodNumberThreshold", 250, UTF8String ("Nombre maximum de vertex topologiques à afficher lors d'interactions.", Charset::UTF_8)),
_topoEdgeLodNumberThreshold ("topoEdgeLodNumberThreshold", 250, UTF8String ("Nombre maximum d'arêtes topologiques à afficher lors d'interactions.", Charset::UTF_8)),
_topoFaceLodNumberThreshold ("topoFaceLodNumberThreshold", 250, UTF8String ("Nombre maximum de faces topologiques à afficher lors d'interactions.", Charset::UTF_8)),
_topoBlockLodNumberThreshold ("topoBlockLodNumberThreshold", 250, UTF8String ("Nombre maximum de blocs topologiques à afficher lors d'interactions.", Charset::UTF_8)),

_organisation ("CEA.DAM.DSSI"),
_softwareName ("Magix3D"),
Expand Down
11 changes: 10 additions & 1 deletion src/Core/protected/Internal/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ class Resources
* Le prémaillage des arêtes, faces et blocs peut il être décomposé en plusieurs tâches exécutées parallèlement dans plusieurs threads ?
*/
Preferences::BoolNamedValue _allowThreadedEdgePreMeshTasks, _allowThreadedFacePreMeshTasks, _allowThreadedBlockPreMeshTasks;


/** La taille des points/noeuds/vertex lors des interactions. */
Preferences::UnsignedLongNamedValue _lodPointSize;

/** L'épaisseur des lignes/arêtes lors des interactions. */
Preferences::UnsignedLongNamedValue _lodLineWidth;

/**
* La police de caractères à utiliser pour les affichages 2D dans la fenêtre graphique. */
Preferences::StringNamedValue _fontFamily;
Expand Down Expand Up @@ -460,6 +466,9 @@ class Resources
*/
Preferences::BoolNamedValue _meshDestroyOnHide;

/** Les nombres d'entités maximum à afficher lors d'interactions. */
Preferences::UnsignedLongNamedValue _topoVertexLodNumberThreshold, _topoEdgeLodNumberThreshold, _topoFaceLodNumberThreshold, _topoBlockLodNumberThreshold;

/** Les scripts à exécuter au lancement de l'application (arguments de ligne de commande suivant -scripts. */
std::vector<std::string> _scripts;

Expand Down
12 changes: 12 additions & 0 deletions src/QtComponents/QtMgx3DApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ void QtMgx3DApplication::applyConfiguration (const Section& mainSection)
Section& geomSection = representationsSection.getSection ("geomEntities");
Section& topoSection = representationsSection.getSection ("topoEntities");
Section& meshSection = representationsSection.getSection ("meshEntities");
PreferencesHelper::getUnsignedLong (representationsSection, Resources::instance ( )._lodPointSize);
PreferencesHelper::getUnsignedLong (representationsSection, Resources::instance ( )._lodLineWidth);
PreferencesHelper::getString (representationsSection, Resources::instance ( )._fontFamily);
DisplayProperties::_defaultFontFamily = fontNameToInt (Resources::instance ( )._fontFamily.getValue ( ));
PreferencesHelper::getUnsignedLong (representationsSection, Resources::instance ( )._fontSize);
Expand All @@ -708,6 +710,10 @@ void QtMgx3DApplication::applyConfiguration (const Section& mainSection)
PreferencesHelper::getBoolean (geomSection, Resources::instance ( )._geomDestroyOnHide);
PreferencesHelper::getBoolean (topoSection, Resources::instance ( )._topoDestroyOnHide);
PreferencesHelper::getBoolean (meshSection, Resources::instance ( )._meshDestroyOnHide);
PreferencesHelper::getUnsignedLong (topoSection, Resources::instance ( )._topoVertexLodNumberThreshold);
PreferencesHelper::getUnsignedLong (topoSection, Resources::instance ( )._topoEdgeLodNumberThreshold);
PreferencesHelper::getUnsignedLong (topoSection, Resources::instance ( )._topoFaceLodNumberThreshold);
PreferencesHelper::getUnsignedLong (topoSection, Resources::instance ( )._topoBlockLodNumberThreshold);

Internal::InternalPreferences::instance ( ).loadPreferences(representationsSection);
}
Expand Down Expand Up @@ -1012,13 +1018,19 @@ void QtMgx3DApplication::saveConfiguration (Section& mainSection)
Section& geomSection = PreferencesHelper::getSection (representationsSection, "geomEntities");
Section& topoSection = PreferencesHelper::getSection (representationsSection, "topoEntities");
Section& meshSection = PreferencesHelper::getSection (representationsSection, "meshEntities");
PreferencesHelper::updateUnsignedLong (representationsSection, Resources::instance ( )._lodPointSize);
PreferencesHelper::updateUnsignedLong (representationsSection, Resources::instance ( )._lodLineWidth);
PreferencesHelper::updateString (representationsSection, Resources::instance ( )._fontFamily);
PreferencesHelper::updateUnsignedLong (representationsSection, Resources::instance ( )._fontSize);
PreferencesHelper::updateBoolean (representationsSection, Resources::instance ( )._fontBold);
PreferencesHelper::updateBoolean (representationsSection, Resources::instance ( )._fontItalic);
PreferencesHelper::updateBoolean (geomSection, Resources::instance ( )._geomDestroyOnHide);
PreferencesHelper::updateBoolean (topoSection, Resources::instance ( )._topoDestroyOnHide);
PreferencesHelper::updateBoolean (meshSection, Resources::instance ( )._meshDestroyOnHide);
PreferencesHelper::updateUnsignedLong (topoSection, Resources::instance ( )._topoVertexLodNumberThreshold);
PreferencesHelper::updateUnsignedLong (topoSection, Resources::instance ( )._topoEdgeLodNumberThreshold);
PreferencesHelper::updateUnsignedLong (topoSection, Resources::instance ( )._topoFaceLodNumberThreshold);
PreferencesHelper::updateUnsignedLong (topoSection, Resources::instance ( )._topoBlockLodNumberThreshold);
Internal::InternalPreferences::instance ( ).savePreferences(representationsSection);

// Interacteur :
Expand Down
4 changes: 2 additions & 2 deletions src/QtComponents/RenderedEntityRepresentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Color RenderedEntityRepresentation::getBaseColor (unsigned long mask) const
float RenderedEntityRepresentation::getPointSize (
const Entity& entity, unsigned long mask)
{
const DisplayProperties properties = getDisplayPropertiesAttributes ( );
// const DisplayProperties properties = getDisplayPropertiesAttributes ( );
const DisplayProperties::GraphicalRepresentation* rep =
entity.getDisplayProperties ( ).getGraphicalRepresentation ( );
float pointSize = entity.getDisplayProperties ( ).getPointSize ( );
Expand All @@ -235,7 +235,7 @@ float RenderedEntityRepresentation::getPointSize (
float RenderedEntityRepresentation::getLineWidth (
const Entity& entity, unsigned long mask)
{
float lineWidth = 1;
float lineWidth = 1.;
//const DisplayProperties& properties = entity.getDisplayProperties ( );
const DisplayProperties properties = getDisplayPropertiesAttributes ( );
const DisplayProperties::GraphicalRepresentation* rep =
Expand Down
66 changes: 63 additions & 3 deletions src/QtVtkComponents/VTKMgx3DActor.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "Internal/ContextIfc.h"
#include "Internal/Resources.h"
#include "QtVtkComponents/vtkMgx3DInteractorStyle.h"

#include "QtVtkComponents/VTKMgx3DActor.h"
#include "Utils/DisplayProperties.h"
Expand All @@ -7,20 +9,27 @@
#include <vtkRenderer.h>

#include <assert.h>
#include <random>


using namespace std;
using namespace Mgx3D::Utils;
using namespace Mgx3D::Internal;


// On préfère uniform_int_distribution à random pour avoir une distribution homogène des nombres aléatoires :
static random_device rd; // a seed source for the random number engine
static mt19937 gen (rd ( )); // mersenne_twister_engine seeded with rd()
static uniform_int_distribution<> distrib (0, 100);

VTKMgx3DActor::VTKMgx3DActor ( )
: vtkLODActor ( ), _entity (0), _representationType ((DisplayRepresentation::type)0)
: vtkLODActor ( ), _entity (0), _representationType ((DisplayRepresentation::type)0), _lodAlea (distrib (gen))
{
} // VTKMgx3DActor::VTKMgx3DActor


VTKMgx3DActor::VTKMgx3DActor (const VTKMgx3DActor&)
: vtkLODActor ( ), _entity (0), _representationType ((DisplayRepresentation::type)0)
: vtkLODActor ( ), _entity (0), _representationType ((DisplayRepresentation::type)0), _lodAlea (-1)
{
assert (0 && "VTKMgx3DActor copy constructor is not allowed.");
} // VTKMgx3DActor copy constructor
Expand Down Expand Up @@ -63,7 +72,9 @@ const char* VTKMgx3DActor::GetClassName ( )

void VTKMgx3DActor::Render (vtkRenderer* renderer, vtkMapper* mapper)
{
//cout << __FILE__ << ' ' << __LINE__ << " VTKMgx3DActor::Render ALLOCATED RENDER TIME = " << AllocatedRenderTime << " ESTIMATED RENDER TIME = " << EstimatedRenderTime << " SAVED ESTIMATED RENDER TIME = " << SavedEstimatedRenderTime << " RENDERER ALLOCATED TIME = " << renderer->GetAllocatedRenderTime ( ) << endl;
if (0 == GetEntity ( ))
return;

vtkLODActor::Render (renderer, mapper);
} // VTKMgx3DActor::Render

Expand Down Expand Up @@ -120,6 +131,55 @@ bool VTKMgx3DActor::IsWire ( ) const
} // VTKMgx3DActor::IsWire


bool VTKMgx3DActor::IsLodDisplayable ( ) const
{
if (0 == GetEntity ( ))
return false;

// On veut qu'à cet instant au plus Resources::instance ( )._topo*LodNumberThreshold.getValue ( ) soit affiché.
// _lodAlea est un nombre aléatoire compris entre 0 et 100 à l'acteur.
switch (GetEntity ( )->getType ( ))
{
case Entity::TopoVertex :
{
const size_t topoVertexLodNumberThreshold = Resources::instance ( )._topoVertexLodNumberThreshold.getValue ( );
const int threshold = (int)(100. * topoVertexLodNumberThreshold / (double)Entity::getDisplayedTopoVertexCount ( ));
if ((_lodAlea >= threshold) && (Entity::getDisplayedTopoVertexCount ( ) > topoVertexLodNumberThreshold))
return false;
}
break;
case Entity::TopoEdge :
case Entity::TopoCoEdge :
{
const size_t topoEdgeLodNumberThreshold = Resources::instance ( )._topoEdgeLodNumberThreshold.getValue ( );
const int threshold = (int)(100. * topoEdgeLodNumberThreshold / (double)Entity::getDisplayedTopoEdgeCount ( ));
if ((_lodAlea >= threshold) && (Entity::getDisplayedTopoEdgeCount ( ) > topoEdgeLodNumberThreshold))
return false;
}
break;
case Entity::TopoFace :
case Entity::TopoCoFace :
{
const size_t topoFaceLodNumberThreshold = Resources::instance ( )._topoFaceLodNumberThreshold.getValue ( );
const int threshold = (int)(100. * topoFaceLodNumberThreshold / (double)Entity::getDisplayedTopoFaceCount ( ));
if ((_lodAlea >= threshold) && (Entity::getDisplayedTopoFaceCount ( ) > topoFaceLodNumberThreshold))
return false;
}
break;
case Entity::TopoBlock :
{
const size_t topoBlockLodNumberThreshold = Resources::instance ( )._topoBlockLodNumberThreshold.getValue ( );
const int threshold = (int)(100. * topoBlockLodNumberThreshold / (double)Entity::getDisplayedTopoBlockCount ( ));
if ((_lodAlea >= threshold) && (Entity::getDisplayedTopoBlockCount ( ) > topoBlockLodNumberThreshold))
return false;
}
break;
} // switch (GetEntity ( )->getType ( ))

return true;
} // VTKMgx3DActor::IsLodDisplayable


void VTKMgx3DActor::CreateOwnLODs ( )
{
// On ne veut pas de LODs pour les entités topologiques :
Expand Down
16 changes: 12 additions & 4 deletions src/QtVtkComponents/protected/QtVtkComponents/VTKMgx3DActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,15 @@ class VTKMgx3DActor : public vtkLODActor
* \param Le type de représentation portée par l'acteur.
* \see GetRepresentationType
*/
virtual void SetRepresentationType (
Mgx3D::Utils::DisplayRepresentation::type);
virtual void SetRepresentationType (Mgx3D::Utils::DisplayRepresentation::type);

/**
* \return Le type de représentation portée par l'acteur.
* \see setRepresentationType
* \see IsSolid
* \see IsWire
*/
virtual Mgx3D::Utils::DisplayRepresentation::type
GetRepresentationType ( ) const;
virtual Mgx3D::Utils::DisplayRepresentation::type GetRepresentationType ( ) const;

/**
* \return <I>true</I> si la représentation est solide, <I>false</I>
Expand All @@ -90,6 +88,13 @@ class VTKMgx3DActor : public vtkLODActor
*/
virtual bool IsWire ( ) const;

/**
* \return <I>true</I> si lors d'une interaction l'acteur doit être représenté en mode LOD (Level Of Detail) au sens
* Magix3D. En VTK en mode LOD une donnée sur n d'un dataset est représentée. Dans Magix3D la plupart des
* datasets ne contiennent qu'une donnée, et, en mode LOD, c'est un acteur sur n qui et affiché.
*/
virtual bool IsLodDisplayable ( ) const;


protected :

Expand All @@ -111,6 +116,9 @@ class VTKMgx3DActor : public vtkLODActor

/** Le type de représentation de l'acteur. */
Mgx3D::Utils::DisplayRepresentation::type _representationType;

/** Un nombre aléatoire compris entre 0 et 100 pour savoir si l'acteur doit être affiché en mode LOD. */
long _lodAlea;
}; // class VTKMgx3DActor


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <vtkSmartPointer.h>
#include <vtkUnsignedCharArray.h>

#include <vector>


/** <P>En plus de la classe <I>vtkUnifiedInteractorStyle</I> permet :<BR>
* <OL>
Expand Down Expand Up @@ -75,6 +77,25 @@ class vtkMgx3DInteractorStyle : public vtkUnifiedInteractorStyle
*/
virtual void PrintSelf (ostream& os, vtkIndent indent);

/**
* Une interaction est-elle en cours dans cette session Magix3D ?
*/
static bool InInteraction ( );

/**
* Affecte true à inInteraction puis vtkUnifiedInteractorStyle::StartState (newstate).
* Désactive l'affichage des vtkMgx3DActor dont <I>IsLodDisplayable ( )</I> retourne
* <I>false</I>, et paramètre les autres en affichage LOD (points/arêtes plus petits).
*/
virtual void StartState (int newstate);

/**
* Affecte false à inInteraction puis vtkUnifiedInteractorStyle::StopState ( ), puis
* restaure les paramètres d'affichage normaux des vtkMgx3DActor affichés, et restaure
* l'affichage des vtkMgx3DActor suspendus.
*/
virtual void StopState ( );

/** <P>Surcharge les actions suivantes :<BR>
* <OL>
* <LI> <I>h</I> : l'entité sélectionnée est masquée
Expand Down Expand Up @@ -224,6 +245,8 @@ class vtkMgx3DInteractorStyle : public vtkUnifiedInteractorStyle
* \see SetInteractiveSelectionActivated
*/
virtual void OnRightButtonUp ( );

virtual void OnMiddleButtonUp ( );

/**
* \param Gestionnaire de sélection <I>Magix 3D</I> associé.
Expand Down Expand Up @@ -303,6 +326,12 @@ class vtkMgx3DInteractorStyle : public vtkUnifiedInteractorStyle
vtkMgx3DInteractorStyle (const vtkMgx3DInteractorStyle&);
vtkMgx3DInteractorStyle& operator = (const vtkMgx3DInteractorStyle&);

/** Une interaction utilisateur est-elle en cours dans cette session Magix3D ? */
static bool InUserInteraction;

/** Les acteurs suspendus lors d'une interaction dans la session Magix3D (émulation de mode LOD avec des acteurs n'affichant qu'une donnée. */
static std::vector<vtkActor*> SuspendedActors;

/** Outils de sélection interactive à la souris. */
Mgx3D::QtVtkComponents::VTKMgx3DPicker* Mgx3DPicker;
Mgx3D::QtVtkComponents::VTKMgx3DPickerCommand* Mgx3DPickerCommand;
Expand Down Expand Up @@ -331,7 +360,7 @@ class vtkMgx3DInteractorStyle : public vtkUnifiedInteractorStyle

/** Vaut <I>true</I> en mode sélection au <I>rectangle élastique</I> lorsque une entité doit être complétement dans le rectangle pour être sélectionnée,
* <I>false</I> (défaut) si une intersection suffit. */
bool CompletelyInsideSelection;
bool CompletelyInsideSelection;

/** Position du curseur de la souris au moment où le bouton est pressé. */
int ButtonPressPosition [2];
Expand Down
Loading