diff --git a/cmake/version.cmake b/cmake/version.cmake index b1d739fb..0a5b5a61 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -4,6 +4,6 @@ set (MAGIX3D_MAJOR_VERSION "2") set (MAGIX3D_MINOR_VERSION "5") -set (MAGIX3D_RELEASE_VERSION "1") +set (MAGIX3D_RELEASE_VERSION "2") set (MAGIX3D_VERSION ${MAGIX3D_MAJOR_VERSION}.${MAGIX3D_MINOR_VERSION}.${MAGIX3D_RELEASE_VERSION}) diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 46479c12..75c4ccbe 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -7,10 +7,10 @@ find_package (GUIToolkitsVariables REQUIRED) include (${GUIToolkitsVariables_CMAKE_DIR}/python_binding.cmake) file (GLOB HEADERS protected/*/*.h) -file (GLOB CPP_SOURCES Internal/*.cpp Geom/*.cpp Topo/*.cpp Mesh/*.cpp Structured/*.cpp Group/*.cpp SysCoord/*.cpp Smoothing/*.cpp ) +file (GLOB CPP_SOURCES Internal/*.cpp Geom/*.cpp Topo/*.cpp Mesh/*.cpp Services/*.cpp Structured/*.cpp Group/*.cpp SysCoord/*.cpp Smoothing/*.cpp ) # Répertoire d'en-têtes installés. Certains sont optionnels et ajoutés plus loin. -set (HEADERS_DIRECTORIES protected/Geom protected/Group protected/Internal protected/Mesh protected/Smoothing protected/Structured protected/SysCoord protected/Topo) +set (HEADERS_DIRECTORIES protected/Geom protected/Group protected/Internal protected/Mesh protected/Services protected/Smoothing protected/Structured protected/SysCoord protected/Topo) # On ajoute les en-têtes aux sources. C'est utile pour cmake dans certains cas, # par exemple lorsqu'ils doivent être pré-processés (moc, ...). diff --git a/src/Core/Geom/CommandCreateWithOtherGeomEntities.cpp b/src/Core/Geom/CommandCreateWithOtherGeomEntities.cpp index 99a7c462..0f4c0651 100644 --- a/src/Core/Geom/CommandCreateWithOtherGeomEntities.cpp +++ b/src/Core/Geom/CommandCreateWithOtherGeomEntities.cpp @@ -31,7 +31,7 @@ void CommandCreateWithOtherGeomEntities::internalUndo() AutoReferencedMutex autoMutex (getMutex ( )); // permute toutes les propriétés internes avec leur sauvegarde - m_memento_manager.permMementos(); + m_memento_service.permMementos(); // les entités détruites sont dites créées et inversement getInfoCommand().permCreatedDeleted(); @@ -50,7 +50,7 @@ void CommandCreateWithOtherGeomEntities::internalRedo() startingOrcompletionLog (true); // permute toutes les propriétés internes avec leur sauvegarde - m_memento_manager.permMementos(); + m_memento_service.permMementos(); // les entités détruites sont dites créées et inversement getInfoCommand().permCreatedDeleted(); diff --git a/src/Core/Geom/CommandEditGeom.cpp b/src/Core/Geom/CommandEditGeom.cpp index a5bd6fb6..b508bb93 100644 --- a/src/Core/Geom/CommandEditGeom.cpp +++ b/src/Core/Geom/CommandEditGeom.cpp @@ -45,14 +45,14 @@ void CommandEditGeom::internalExecute() internalSpecificPreExecute(); // on recupere toutes les entites concernes par l'opération géométrique - std::map mementos_by_entity; + std::map mementos_by_entity; std::set to_mem_entities[4]; for(unsigned int i=0;i<4;i++) { to_mem_entities[i].insert(getRefEntities(i).begin(), getRefEntities(i).end()); to_mem_entities[i].insert(getAdjEntities(i).begin(), getAdjEntities(i).end()); for (GeomEntity* e : to_mem_entities[i]) { - MementoEntity mem = m_memento_manager.createMemento(e); + Services::Memento mem = m_memento_service.createMemento(e); #ifdef _DEBUG2 std::cerr<<"Memento cree pour "<getName()< keeped_ref; + std::map keeped_ref; for(unsigned int i=0;i & candidates) +saveMementos(std::map & candidates) { for (const auto& pair : candidates) { - m_memento_manager.saveMemento(pair.first, pair.second); + m_memento_service.saveMemento(pair.first, pair.second); #ifdef _DEBUG_CANCEL std::cout<<"save Memento pour "<getName()<getZ ( )) << ")."; // sauvegarde des relations (connections topologiques) avant modification - m_memento_manager.saveMemento(m_v1); - m_memento_manager.saveMemento(m_v2); + m_memento_service.saveMemento(m_v1); + m_memento_service.saveMemento(m_v2); Curve* c = EntityFactory(getContext()).newSegment(m_v1,m_v2); m_createdEntities.push_back(c); diff --git a/src/Core/Geom/CommandNewSurface.cpp b/src/Core/Geom/CommandNewSurface.cpp index 205a71b3..43148dc6 100644 --- a/src/Core/Geom/CommandNewSurface.cpp +++ b/src/Core/Geom/CommandNewSurface.cpp @@ -55,7 +55,7 @@ internalExecute() */ // sauvegarde des relations (connections topologiques) avant modification for (uint i=0; i @@ -115,32 +113,6 @@ bool Curve::isEqual(Geom::Curve* curve) return true; } /*----------------------------------------------------------------------------*/ -void Curve::get(std::vector& coedges) -{ - const std::vector& topos = getRefTopo(); - - for (std::vector::const_iterator iter = topos.begin(); - iter != topos.end(); ++iter) - if ((*iter)->getDim() == 1){ - Topo::CoEdge* coedge = dynamic_cast(*iter); - if (coedge) - coedges.push_back(coedge); - } -} -/*----------------------------------------------------------------------------*/ -void Curve::get(std::vector& vertices) -{ - const std::vector& topos = getRefTopo(); - - for (std::vector::const_iterator iter = topos.begin(); - iter != topos.end(); ++iter) - if ((*iter)->getDim() == 0){ - Topo::Vertex* vertex = dynamic_cast(*iter); - if (vertex) - vertices.push_back(vertex); - } -} -/*----------------------------------------------------------------------------*/ void Curve:: getPoint(const double& p, Utils::Math::Point& Pt, const bool in01) const { @@ -703,17 +675,6 @@ void Curve::getGroups(std::vector& grp) const grp.insert(grp.end(), m_groups.begin(), m_groups.end()); } /*----------------------------------------------------------------------------*/ -void Curve::setGroups(std::vector& grp) -{ - m_groups.clear(); - for (std::vector::iterator iter = grp.begin(); iter != grp.end(); iter++){ - Group::Group1D* g1 = dynamic_cast(*iter); - if (g1 == 0) - throw TkUtil::Exception(TkUtil::UTF8String ("Erreur interne avec conversion en groupe local dans setGroups", TkUtil::Charset::UTF_8)); - m_groups.push_back(g1); - } -} -/*----------------------------------------------------------------------------*/ int Curve::getNbGroups() const { return m_groups.size(); @@ -772,95 +733,6 @@ bool Curve::isBSpline() const return false; } /*----------------------------------------------------------------------------*/ -Utils::SerializedRepresentation* Curve::getDescription (bool alsoComputed) const -{ - std::unique_ptr description ( - GeomEntity::getDescription (alsoComputed)); - CHECK_NULL_PTR_ERROR (description.get ( )) - - Utils::SerializedRepresentation propertyGeomDescription ( - "Propriétés géométriques", ""); - - if (true == alsoComputed) - { - //recuperation de la longueur - TkUtil::UTF8String volStr (TkUtil::Charset::UTF_8); - volStr<1) - typeStr<<"composée"; - else - typeStr<<"quelconque"; - - propertyGeomDescription.addProperty ( - Utils::SerializedRepresentation::Property ("Type", typeStr)); - -#ifdef _DEBUG - if (isABSpline){ - TkUtil::UTF8String nbStr1 (TkUtil::Charset::UTF_8); - TkUtil::UTF8String nbStr2 (TkUtil::Charset::UTF_8); - - // c'est une spline => une seule représentation de type Edge - TopoDS_Edge edge = m_occ_edges[0]; - Standard_Real first_param, last_param; - Handle_Geom_Curve curve = BRep_Tool::Curve(edge, first_param, last_param); - - Handle(Geom_BSplineCurve) bspline = Handle(Geom_BSplineCurve)::DownCast(curve); - - nbStr1<<(long int)bspline->NbKnots(); - nbStr2<<(long int)bspline->NbPoles(); - - propertyGeomDescription.addProperty ( - Utils::SerializedRepresentation::Property ("Nb noeuds", nbStr1.ascii()) ); - propertyGeomDescription.addProperty ( - Utils::SerializedRepresentation::Property ("Nb poles", nbStr2.ascii()) ); - } - - // affichage des paramètres extrémas - double first, last; - getParameters(first, last); - TkUtil::UTF8String param1 (TkUtil::Charset::UTF_8); - param1<addPropertiesSet (propertyGeomDescription); - - return description.release ( ); -} -/*----------------------------------------------------------------------------*/ } // end namespace Geom /*----------------------------------------------------------------------------*/ } // end namespace Mgx3D diff --git a/src/Core/Geom/GeomEntity.cpp b/src/Core/Geom/GeomEntity.cpp index 4516baf8..20df6aed 100644 --- a/src/Core/Geom/GeomEntity.cpp +++ b/src/Core/Geom/GeomEntity.cpp @@ -10,11 +10,7 @@ #include "Geom/OCCFacetedRepresentationBuilder.h" #include "Geom/IncidentGeomEntitiesVisitor.h" /*----------------------------------------------------------------------------*/ -#include "Topo/TopoEntity.h" -#include "Topo/Vertex.h" -#include "Topo/CoEdge.h" -#include "Topo/CoFace.h" -#include "Topo/Block.h" +#include "Services/DescriptionService.h" /*----------------------------------------------------------------------------*/ #include "Group/Group0D.h" #include "Group/Group1D.h" @@ -96,154 +92,9 @@ getRepresentation(Utils::DisplayRepresentation& dr, bool checkDestroyed) const pts[i] = (barycentre + (pts[i] - barycentre) * shrink); } /*----------------------------------------------------------------------------*/ -template -void GeomEntity:: -buildSerializedRepresentation(Utils::SerializedRepresentation& description, const std::string& title, - const Utils::EntitySet elements) const +Mgx3D::Utils::SerializedRepresentation* GeomEntity::getDescription (bool alsoComputed) const { - if (!elements.empty()){ - Utils::SerializedRepresentation sr (title,TkUtil::NumericConversions::toStr(elements.size())); - for (auto elt : elements) - sr.addProperty (Utils::SerializedRepresentation::Property(elt->getName(),*elt)); - description.addPropertiesSet (sr); - } -} -/*----------------------------------------------------------------------------*/ -template -void GeomEntity:: -buildSerializedRepresentation(Utils::SerializedRepresentation& description, const std::string& title, - const std::vector elements) const -{ - if (!elements.empty()){ - Utils::SerializedRepresentation sr (title,TkUtil::NumericConversions::toStr(elements.size())); - for (auto elt : elements) - sr.addProperty (Utils::SerializedRepresentation::Property(elt->getName(),*elt)); - description.addPropertiesSet (sr); - } -} -/*----------------------------------------------------------------------------*/ -Utils::SerializedRepresentation* GeomEntity:: -getDescription (bool alsoComputed) const -{ - std::unique_ptr description ( - InternalEntity::getDescription (alsoComputed)); - CHECK_NULL_PTR_ERROR (description.get ( )) - - Utils::SerializedRepresentation relationsGeomDescription ("Relations géométriques", ""); - GetUpIncidentGeomEntitiesVisitor vup; - GetDownIncidentGeomEntitiesVisitor vdown; - GetAdjacentGeomEntitiesVisitor vadj; - this->accept(vup); - this->accept(vdown); - this->accept(vadj); - - // On y ajoute les éléments géométriques en relation avec celui-ci : - auto v = vdown.getVertices(); - v.insert(vadj.getVertices().begin(), vadj.getVertices().end()); - buildSerializedRepresentation(relationsGeomDescription, "Sommets", v); - TkUtil::UTF8String summary (TkUtil::Charset::UTF_8); - for (auto vert : v) - summary << vert->getName ( ) <<" "; - description->setSummary(summary.ascii()); - - auto c = vup.getCurves(); - c.insert(vdown.getCurves().begin(), vdown.getCurves().end()); - c.insert(vadj.getCurves().begin(), vadj.getCurves().end()); - buildSerializedRepresentation(relationsGeomDescription, "Courbes", c); - - auto s = vup.getSurfaces(); - s.insert(vdown.getSurfaces().begin(), vdown.getSurfaces().end()); - s.insert(vadj.getSurfaces().begin(), vadj.getSurfaces().end()); - buildSerializedRepresentation(relationsGeomDescription, "Surfaces", s); - - auto vol = vup.getVolumes(); - vol.insert(vadj.getVolumes().begin(), vadj.getVolumes().end()); - buildSerializedRepresentation(relationsGeomDescription, "Volumes", vol); - - description->addPropertiesSet (relationsGeomDescription); - - // la Topologie s'il y en a une - if (!m_topo_entities.empty()){ - Utils::SerializedRepresentation topoDescription ("Relations topologiques", ""); - - std::vector v; - std::vector e; - std::vector f; - std::vector b; - - for (std::vector::const_iterator iter = m_topo_entities.begin(); - iter != m_topo_entities.end(); ++iter){ - if ((*iter)->getDim() == 0) - v.push_back(dynamic_cast(*iter)); - else if ((*iter)->getDim() == 1) - e.push_back(dynamic_cast(*iter)); - else if ((*iter)->getDim() == 2) - f.push_back(dynamic_cast(*iter)); - else if ((*iter)->getDim() == 3) - b.push_back(dynamic_cast(*iter)); - } - - buildSerializedRepresentation(topoDescription, "Sommets topologiques", v); - buildSerializedRepresentation(topoDescription, "Arêtes topologiques", e); - buildSerializedRepresentation(topoDescription, "Faces topologiques", f); - buildSerializedRepresentation(topoDescription, "Blocs topologiques", b); - - description->addPropertiesSet (topoDescription); - } else { - description->addProperty ( - Utils::SerializedRepresentation::Property ( - "Relations topologiques", std::string("Aucune"))); - } - - // Les groupes s'il y en a - std::vector grp; - getGroups(grp); - if (!grp.empty()){ - Utils::SerializedRepresentation groupeDescription ("Relations vers des groupes", ""); - - std::vector g0; - std::vector g1; - std::vector g2; - std::vector g3; - - for (std::vector::const_iterator iter = grp.begin(); - iter != grp.end(); ++iter){ - if ((*iter)->getDim() == 0) - g0.push_back(dynamic_cast(*iter)); - else if ((*iter)->getDim() == 1) - g1.push_back(dynamic_cast(*iter)); - else if ((*iter)->getDim() == 2) - g2.push_back(dynamic_cast(*iter)); - else if ((*iter)->getDim() == 3) - g3.push_back(dynamic_cast(*iter)); - } - - buildSerializedRepresentation(groupeDescription, "Groupes 0D", g0); - buildSerializedRepresentation(groupeDescription, "Groupes 1D", g1); - buildSerializedRepresentation(groupeDescription, "Groupes 2D", g2); - buildSerializedRepresentation(groupeDescription, "Groupes 3D", g3); - - description->addPropertiesSet (groupeDescription); - groupeDescription.setSummary(TkUtil::NumericConversions::toStr(grp.size())); - } else { - description->addProperty ( - Utils::SerializedRepresentation::Property ( - "Relations vers des groupes", std::string("Aucune"))); - } - -#ifdef _DEBUG - Utils::SerializedRepresentation occGeomDescription ("Propriétés OCC", ""); - // observation du HashCode retourné par OCC - - auto add_description = [&](const TopoDS_Shape& sh) { - int hc = sh.HashCode(INT_MAX); - occGeomDescription.addProperty (Utils::SerializedRepresentation::Property ("HashCode", (long int)hc)); - }; - this->apply(add_description); - description->addPropertiesSet (occGeomDescription); -#endif - - return description.release ( ); + return Services::DescriptionService::getDescription(this, alsoComputed); } /*----------------------------------------------------------------------------*/ GeomProperty::type GeomEntity::getGeomType ( ) const @@ -252,51 +103,6 @@ GeomProperty::type GeomEntity::getGeomType ( ) const return getGeomProperty ( )->getType ( ); } // GeomEntity::getGeomType /*----------------------------------------------------------------------------*/ -void GeomEntity::addRefTopo(Topo::TopoEntity* te) -{ -#ifdef _DEBUG2 - std::cout<<"GeomEntity::addRefTopo("<<(te?te->getName():"0")<<") à "<getName():"0")<<") à "<getName(); -// std::cout<& vte) const -{ - vte.clear(); - vte.insert(vte.end(), m_topo_entities.begin(), m_topo_entities.end()); -} -/*----------------------------------------------------------------------------*/ void GeomEntity::getGroupsName (std::vector& gn) const { MGX_FORBIDDEN("getGroupsName est à redéfinir dans les classes dérivées"); @@ -307,11 +113,6 @@ void GeomEntity::getGroups(std::vector& grp) const MGX_FORBIDDEN("getGroups est à redéfinir dans les classes dérivées"); } /*----------------------------------------------------------------------------*/ -void GeomEntity::setGroups(std::vector& grp) -{ - MGX_FORBIDDEN("setGroups est à redéfinir dans les classes dérivées"); -} -/*----------------------------------------------------------------------------*/ int GeomEntity::getNbGroups() const { MGX_FORBIDDEN("getNbGroups est à redéfinir dans les classes dérivées"); diff --git a/src/Core/Geom/GeomInfo.cpp b/src/Core/Geom/GeomInfo.cpp deleted file mode 100644 index a9fd4373..00000000 --- a/src/Core/Geom/GeomInfo.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*----------------------------------------------------------------------------*/ -#include "Geom/GeomInfo.h" -#include "Geom/Vertex.h" -#include "Geom/Curve.h" -#include "Geom/Surface.h" -#include "Geom/Volume.h" -#include "Topo/TopoEntity.h" -/*----------------------------------------------------------------------------*/ -namespace Mgx3D { -/*----------------------------------------------------------------------------*/ -namespace Geom { -/*----------------------------------------------------------------------------*/ -std::vector GeomInfo::vertices() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector GeomInfo::curves() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector GeomInfo::surfaces() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector GeomInfo::volumes() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector GeomInfo::topoEntities() const -{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector GeomInfo::groupsName() const -{ - return groups_name; -} -/*----------------------------------------------------------------------------*/ -} // end namespace Geom -/*----------------------------------------------------------------------------*/ -} // end namespace Mgx3D -/*----------------------------------------------------------------------------*/ diff --git a/src/Core/Geom/GeomManager.cpp b/src/Core/Geom/GeomManager.cpp index be50bb59..f5fe6a04 100644 --- a/src/Core/Geom/GeomManager.cpp +++ b/src/Core/Geom/GeomManager.cpp @@ -90,6 +90,7 @@ #include "Topo/CommandExtrudeTopo.h" #include "Topo/TopoHelper.h" #include "SysCoord/SysCoord.h" +#include "Services/InfoService.h" #ifdef USE_MDLPARSER #include "Internal/CommandChangeLengthUnit.h" #endif @@ -168,36 +169,40 @@ Geom::GeomInfo GeomManager::getInfos(std::string name, int dim) /*----------------------------------------------------------------------------*/ Geom::GeomInfo GeomManager::getInfos(const GeomEntity* e) { - Geom::GeomInfo infos; - infos.name = e->getName(); - infos.dimension = e->getDim(); - infos.area = e->computeArea(); - - GetUpIncidentGeomEntitiesVisitor vup; - GetDownIncidentGeomEntitiesVisitor vdown; - GetAdjacentGeomEntitiesVisitor vadj; - e->accept(vup); - e->accept(vdown); - e->accept(vadj); - - // On y ajoute les éléments géométriques en relation avec celui-ci : - infos.incident_vertices.insert(infos.incident_vertices.end(), vdown.getVertices().begin(), vdown.getVertices().end()); - infos.incident_vertices.insert(infos.incident_vertices.end(), vadj.getVertices().begin(), vadj.getVertices().end()); - - infos.incident_curves.insert(infos.incident_curves.end(), vup.getCurves().begin(), vup.getCurves().end()); - infos.incident_curves.insert(infos.incident_curves.end(), vdown.getCurves().begin(), vdown.getCurves().end()); - infos.incident_curves.insert(infos.incident_curves.end(), vadj.getCurves().begin(), vadj.getCurves().end()); - - infos.incident_surfaces.insert(infos.incident_surfaces.end(), vup.getSurfaces().begin(), vup.getSurfaces().end()); - infos.incident_surfaces.insert(infos.incident_surfaces.end(), vdown.getSurfaces().begin(), vdown.getSurfaces().end()); - infos.incident_surfaces.insert(infos.incident_surfaces.end(), vadj.getSurfaces().begin(), vadj.getSurfaces().end()); - - infos.incident_volumes.insert(infos.incident_volumes.end(), vup.getVolumes().begin(), vup.getVolumes().end()); - infos.incident_volumes.insert(infos.incident_volumes.end(), vadj.getVolumes().begin(), vadj.getVolumes().end()); - - e->getRefTopo(infos.topo_entities); - e->getGroupsName(infos.groups_name); - return infos; + return Services::InfoService::getInfos(e); +} +/*----------------------------------------------------------------------------*/ +std::string GeomManager::getTextualDescription(std::string name, int dim) +{ + GeomEntity* e = 0; + switch(dim){ + case(0):{ + e =getVertex(name); + } + break; + case(1):{ + e =getCurve(name); + } + break; + case(2):{ + e =getSurface(name); + } + break; + case(3):{ + e =getVolume(name); + } + break; + default:{ + throw TkUtil::Exception (TkUtil::UTF8String ("Dimension erronée", TkUtil::Charset::UTF_8)); + } + break; + } + return getTextualDescription(e); +} +/*----------------------------------------------------------------------------*/ +std::string GeomManager::getTextualDescription(const GeomEntity* e) +{ + return e->getDescription(true)->toString(); } /*----------------------------------------------------------------------------*/ Utils::Math::Point GeomManager::getCoord(const std::string& name) const @@ -217,15 +222,15 @@ copy(std::vector& e, bool withTopo, std::string groupName) } /*----------------------------------------------------------------------------*/ Internal::M3DCommandResult* GeomManager:: -copy(std::vector& e, bool withTopo, std::string groupName) +copy(std::vector& entities, bool withTopo, std::string groupName) { - CHECK_ENTITIES_LIST(e) + CHECK_ENTITIES_LIST(entities) TkUtil::UTF8String message (TkUtil::Charset::UTF_8); message << "GeomManager::copy ("; - for(unsigned int i=0;igetName(); + message << entities[i]->getName(); } message<<", "<& e, bool withTopo, std::string groupName) Internal::CommandInternal* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (withTopo && Internal::EntitiesHelper::hasTopoRef(e)){ + if (withTopo && hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Copie de géométries avec topologies"); CommandGeomCopy *commandGeom = - new CommandGeomCopy(getContext(),e, groupName); + new CommandGeomCopy(getContext(), entities, groupName); commandCompo->addCommand(commandGeom); Topo::CommandDuplicateTopo* commandTopo = @@ -249,14 +254,14 @@ copy(std::vector& e, bool withTopo, std::string groupName) command = commandCompo; } else { - command = new CommandGeomCopy(getContext(),e,groupName); + command = new CommandGeomCopy(getContext(), entities, groupName); } CHECK_NULL_PTR_ERROR(command); // trace dans le script TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); - cmd << getContextAlias( ) << ".getGeomManager ( ).copy (" << Internal::entitiesToPythonList (e); + cmd << getContextAlias( ) << ".getGeomManager ( ).copy (" << Internal::entitiesToPythonList (entities); if(withTopo) cmd <<", True,\""<& e, bool withTopo, std::string groupName) // et la stocke dans le gestionnaire de undo-redo si c'est une réussite getCommandManager().addCommand(command, Utils::Command::DO); - Internal::M3DCommandResult* cmdResult = - new Internal::M3DCommandResult (*command); + Internal::M3DCommandResult* cmdResult = new Internal::M3DCommandResult (*command); return cmdResult; - } /*----------------------------------------------------------------------------*/ Internal::M3DCommandResult* GeomManager:: @@ -828,7 +831,7 @@ destroy(std::vector& entities, bool propagagetDown) Internal::CommandInternal* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Suppression d'entités géométriques et suppression des liens topologiques"); @@ -897,7 +900,7 @@ destroyWithTopo(std::vector& entities, bool propagagetDown) Internal::CommandInternal* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Suppression d'entités géométriques et suppression des entités topologiques dépendantes"); @@ -974,7 +977,7 @@ scale(std::vector& entities, const double factor, const Point Internal::CommandInternal* command = 0; Geom::CommandEditGeom *commandGeom = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Homothétie d'une géométrie avec sa topologie"); @@ -1098,7 +1101,7 @@ scale(std::vector& entities, Internal::CommandInternal* command = 0; Geom::CommandEditGeom *commandGeom = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Homothétie d'une géométrie avec sa topologie"); @@ -1219,7 +1222,7 @@ copyAndScale(std::vector& entities, const double factor, cons Internal::CommandComposite* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (withTopo && Internal::EntitiesHelper::hasTopoRef(entities)){ + if (withTopo && hasRefTopo(entities)){ command = new Internal::CommandComposite(getContext(), "Homothétie d'une copie d'une géométrie avec sa topologie"); @@ -1374,7 +1377,7 @@ copyAndScale(std::vector& entities, Internal::CommandComposite* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (withTopo && Internal::EntitiesHelper::hasTopoRef(entities)){ + if (withTopo && hasRefTopo(entities)){ command = new Internal::CommandComposite(getContext(), "Homothétie d'une copie d'une géométrie avec sa topologie"); @@ -1513,7 +1516,7 @@ mirror(std::vector& entities, Utils::Math::Plane* plane) Internal::CommandInternal* command = 0; Geom::CommandEditGeom *commandGeom = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Symétrie d'une géométrie avec sa topologie"); @@ -1577,7 +1580,7 @@ copyAndMirror(std::vector& entities, Utils::Math::Plane* plan Internal::CommandComposite* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (withTopo && Internal::EntitiesHelper::hasTopoRef(entities)){ + if (withTopo && hasRefTopo(entities)){ command = new Internal::CommandComposite(getContext(), "Symétrie d'une copie d'une géométrie avec sa topologie"); @@ -2406,7 +2409,7 @@ translate(std::vector& entities, const Vector& dp) Internal::CommandInternal* command = 0; Geom::CommandEditGeom *commandGeom = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Translation d'une géométrie avec sa topologie"); @@ -2497,7 +2500,7 @@ copyAndTranslate(std::vector& entities, const Vector& dp, bool with Internal::CommandComposite* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (withTopo && Internal::EntitiesHelper::hasTopoRef(entities)){ + if (withTopo && hasRefTopo(entities)){ command = new Internal::CommandComposite(getContext(), "Translation d'une copie d'une géométrie avec sa topologie"); @@ -2615,7 +2618,7 @@ joinCurves(std::vector& entities) Internal::CommandInternal* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Fusion de courbes avec maj de la topologie"); @@ -2679,7 +2682,7 @@ joinSurfaces(std::vector& entities) Internal::CommandInternal* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)) + if (hasRefTopo(entities)) { Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Fusion de surfaces avec maj de la topologie"); @@ -2747,7 +2750,7 @@ rotate( std::vector& entities, const Utils::Math::Rotation& rot) Internal::CommandInternal* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Rotation d'une géométrie avec sa topologie"); @@ -2848,7 +2851,7 @@ copyAndRotate( std::vector& entities, Internal::CommandComposite* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (withTopo && Internal::EntitiesHelper::hasTopoRef(entities)){ + if (withTopo && hasRefTopo(entities)){ command = new Internal::CommandComposite(getContext(), "Rotation d'une copie d'une géométrie avec sa topologie"); @@ -3010,7 +3013,7 @@ makeExtrude( std::vector& entities, // trace dans le script TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); - cmd << getContextAlias ( ) << ".getGeomManager ( ).makeExtrude (" << Internal::entitiesToPythonList (entities) << dp.getScriptCommand ( ) << ", " << (keep ? "True":"False") << ")"; + cmd << getContextAlias ( ) << ".getGeomManager ( ).makeExtrude (" << Internal::entitiesToPythonList (entities) << ", " <setScriptCommand(cmd); getCommandManager().addCommand(command, Utils::Command::DO); @@ -3043,7 +3046,7 @@ makeBlocksByExtrude(std::vector& entities, const Utils::Math::Vecto Internal::CommandInternal* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)) + if (hasRefTopo(entities)) { Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Création d'une topologie par extrusion"); @@ -3113,7 +3116,7 @@ fuse(std::vector& entities) Internal::CommandInternal* command = 0; Geom::CommandEditGeom *commandGeom = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Fusion booléenne entre géométries avec topologies"); @@ -3173,7 +3176,7 @@ common(std::vector& entities) Internal::CommandInternal* command = 0; Geom::CommandEditGeom *commandGeom = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Intersection booléenne entre géométries avec topologies"); @@ -3223,7 +3226,7 @@ common2D(Geom::GeomEntity* entity1, Geom::GeomEntity* entity2, std::string group std::vector entities; entities.push_back(entity1); entities.push_back(entity2); - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Intersection booléenne entre 2 géométries 1D ou 2D avec topologies"); @@ -4081,7 +4084,7 @@ cut(Geom::GeomEntity* tokeep, std::vector& tocut) // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? std::vector tokeeps; tokeeps.push_back(tokeep); - if (Internal::EntitiesHelper::hasTopoRef(tokeeps)){ + if (hasRefTopo(tokeeps)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Différences entre géométries avec topologies"); @@ -4160,7 +4163,7 @@ cut(std::vector& tokeep, new Internal::CommandComposite(getContext(), "Différences entre géométries avec plusieurs entités à couper"); // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(tokeep)){ + if (hasRefTopo(tokeep)){ for(unsigned int i=0;i& e Internal::CommandInternal* command = 0; // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Collage entre géométries avec topologies"); @@ -4285,7 +4288,7 @@ Internal::M3DCommandResult* GeomManager::section( std::vector if(entities.size()==1){ // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Section par un plan entre géométries avec topologies"); @@ -4307,7 +4310,7 @@ Internal::M3DCommandResult* GeomManager::section( std::vector } else{ // est-ce qu'il y a une topologie parmis les entités géométriques sélectionnées ? - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo= new Internal::CommandComposite(getContext(), "Section entre géométries avec topologies"); @@ -4405,7 +4408,7 @@ sectionByPlane( std::vector& entities, Internal::CommandInternal* command = 0; - if (Internal::EntitiesHelper::hasTopoRef(entities)){ + if (hasRefTopo(entities)){ Internal::CommandComposite* commandCompo = new Internal::CommandComposite(getContext(), "Section par un plan entre géométries avec topologies"); @@ -5291,6 +5294,25 @@ convert(std::vector& names, std::vector& entities) entities.push_back(getEntity(names[i], true)); } /*----------------------------------------------------------------------------*/ +bool GeomManager:: +hasRefTopo(std::vector& entities) +{ + Topo::TopoManager& tm = getContext().getTopoManager(); + for (uint i=0; i 0) + return true; + + Geom::GetDownIncidentGeomEntitiesVisitor v; + entities[i]->accept(v); + for (auto sub_entity : v.get()) + if (tm.getRefTopos(sub_entity).size() > 0) + return true; + + } // end for i -/*----------------------------------------------------------------------------*/ -namespace Mgx3D { -/*----------------------------------------------------------------------------*/ -namespace Geom { -/*----------------------------------------------------------------------------*/ -const MementoEntity MementoManager:: -createMemento(const GeomEntity* e) const -{ - struct : ConstGeomEntityVisitor { - void visit(const Vertex* v) override { - fillCommonFields(v); - mem.setCurves(const_cast&>(v->getCurves())); - mem.setGroups0D(const_cast&>(v->getGroups())); - std::vector shapes = { v->getOCCVertex() }; - mem.setOCCShapes(shapes); - } - - void visit(const Curve* c) override { - fillCommonFields(c); - mem.setSurfaces(const_cast&>(c->getSurfaces())); - mem.setVertices(const_cast&>(c->getVertices())); - mem.setGroups1D(const_cast&>(c->getGroups())); - std::vector shapes; - for (auto e : c->getOCCEdges()) - shapes.push_back(e); - mem.setOCCShapes(shapes); - } - - void visit(const Surface* s) override { - fillCommonFields(s); - mem.setCurves(const_cast&>(s->getCurves())); - mem.setVolumes(const_cast&>(s->getVolumes())); - mem.setGroups2D(const_cast&>(s->getGroups())); - std::vector shapes; - for (auto f : s->getOCCFaces()) - shapes.push_back(f); - mem.setOCCShapes(shapes); - } - - void visit(const Volume* v) override { - fillCommonFields(v); - mem.setSurfaces(const_cast&>(v->m_surfaces)); - mem.setGroups3D(const_cast&>(v->m_groups)); - mem.setOCCShapes({ v->getOCCShape() }); - } - - void fillCommonFields(const GeomEntity* e) { - mem.setTopoEntities(const_cast&>(e->getRefTopo())); - mem.setProperty(e->getGeomProperty()); - } - - MementoEntity mem; - } create_memento_visitor; - - e->accept(create_memento_visitor); - return create_memento_visitor.mem; -} -/*----------------------------------------------------------------------------*/ -void MementoManager:: -saveMemento(GeomEntity* e, const MementoEntity& mem) -{ - m_mementos.insert({e, mem}); -} -/*----------------------------------------------------------------------------*/ -void MementoManager:: -permMementos() -{ - for(auto it = m_mementos.begin();it!=m_mementos.end();it++){ - GeomEntity *e = it->first; - MementoEntity mem_saved = it->second; - it->second = createMemento(e); - setFromMemento(e, mem_saved); - } -} -/*----------------------------------------------------------------------------*/ -void MementoManager:: -setFromMemento(GeomEntity* e, const MementoEntity& mem) -{ - struct : GeomEntityVisitor { - void visit(Vertex* v) override { - v->m_curves = m_mem.getCurves(); - v->m_groups = m_mem.getGroups0D(); - v->m_occ_vertex = TopoDS::Vertex(m_mem.getOCCShapes()[0]); - setCommonFields(v); - } - - void visit(Curve* c) override { - c->m_surfaces = m_mem.getSurfaces(); - c->m_vertices = m_mem.getVertices(); - c->m_groups = m_mem.getGroups1D(); - c->m_occ_edges.clear(); - for (auto sh : m_mem.getOCCShapes()) - c->m_occ_edges.push_back(TopoDS::Edge(sh)); - setCommonFields(c); - } - - void visit(Surface* s) override { - s->m_curves = m_mem.getCurves(); - s->m_volumes = m_mem.getVolumes(); - s->m_groups = m_mem.getGroups2D(); - s->m_occ_faces.clear(); - for (auto sh : m_mem.getOCCShapes()) - s->m_occ_faces.push_back(TopoDS::Face(sh)); - setCommonFields(s); - } - - void visit(Volume* v) override { - v->m_surfaces = m_mem.getSurfaces(); - v->m_groups = m_mem.getGroups3D(); - v->m_occ_shape = m_mem.getOCCShapes()[0]; - setCommonFields(v); - } - - void setCommonFields(GeomEntity* e) { - e->m_topo_entities = m_mem.getTopoEntities(); - e->m_geomProp = m_mem.getProperty(); - e->m_computedAreaIsUpToDate = false; - } - - MementoEntity m_mem; - } set_memento_visitor; - - set_memento_visitor.m_mem = mem; - e->accept(set_memento_visitor); -} -/*----------------------------------------------------------------------------*/ -} // end namespace Geom -/*----------------------------------------------------------------------------*/ -} // end namespace Mgx3D -/*----------------------------------------------------------------------------*/ \ No newline at end of file diff --git a/src/Core/Geom/Surface_Geom.cpp b/src/Core/Geom/Surface_Geom.cpp index f5e1ae5a..11a1c943 100644 --- a/src/Core/Geom/Surface_Geom.cpp +++ b/src/Core/Geom/Surface_Geom.cpp @@ -6,9 +6,6 @@ #include "Geom/OCCHelper.h" #include "Geom/EntityFactory.h" #include "Geom/GeomProjectImplementation.h" -#include "Topo/CoFace.h" -#include "Topo/CoEdge.h" -#include "Topo/Vertex.h" #include "Group/Group2D.h" /*----------------------------------------------------------------------------*/ #include @@ -264,17 +261,6 @@ void Surface::getGroups(std::vector& grp) const grp.insert(grp.end(), m_groups.begin(), m_groups.end()); } /*----------------------------------------------------------------------------*/ -void Surface::setGroups(std::vector& grp) -{ - m_groups.clear(); - for (std::vector::iterator iter = grp.begin(); iter != grp.end(); iter++){ - Group::Group2D* g2 = dynamic_cast(*iter); - if (g2 == 0) - throw TkUtil::Exception (TkUtil::UTF8String ("Erreur interne avec conversion en groupe local dans setGroups", TkUtil::Charset::UTF_8)); - m_groups.push_back(g2); - } -} -/*----------------------------------------------------------------------------*/ int Surface::getNbGroups() const { return m_groups.size(); @@ -322,92 +308,6 @@ Utils::Math::Point Surface::getPoint(const double u, const double v) const throw TkUtil::Exception (TkUtil::UTF8String ("Parametre u hors de la plage [UMIN, UMAX]", TkUtil::Charset::UTF_8)); } /*----------------------------------------------------------------------------*/ -void Surface::get(std::vector& cofaces) -{ - const std::vector& topos = getRefTopo(); - - for (std::vector::const_iterator iter = topos.begin(); - iter != topos.end(); ++iter) - if ((*iter)->getDim() == 2){ - Topo::CoFace* coface = dynamic_cast(*iter); - if (coface) - cofaces.push_back(coface); - } -} -/*----------------------------------------------------------------------------*/ -void Surface::get(std::vector& coedges) -{ - const std::vector& topos = getRefTopo(); - - for (std::vector::const_iterator iter = topos.begin(); - iter != topos.end(); ++iter) - if ((*iter)->getDim() == 1){ - Topo::CoEdge* coedge = dynamic_cast(*iter); - if (coedge) - coedges.push_back(coedge); - } -} -/*----------------------------------------------------------------------------*/ -void Surface::get(std::vector& vertices) -{ - const std::vector& topos = getRefTopo(); - - for (std::vector::const_iterator iter = topos.begin(); - iter != topos.end(); ++iter) - if ((*iter)->getDim() == 0){ - Topo::Vertex* vertex = dynamic_cast(*iter); - if (vertex) - vertices.push_back(vertex); - } -} -/*----------------------------------------------------------------------------*/ -Utils::SerializedRepresentation* Surface::getDescription (bool alsoComputed) const -{ - std::unique_ptr description ( - GeomEntity::getDescription (alsoComputed)); - CHECK_NULL_PTR_ERROR (description.get ( )) - - Utils::SerializedRepresentation propertyGeomDescription ( - "Propriétés géométriques", ""); - - if (true == alsoComputed) - { - //recuperation de l'aire - TkUtil::UTF8String volStr (TkUtil::Charset::UTF_8); - volStr<1) - typeStr<<"composée"; - else - typeStr<<"quelconque"; - - propertyGeomDescription.addProperty ( - Utils::SerializedRepresentation::Property ("Type", typeStr.ascii()) ); - - description->addPropertiesSet (propertyGeomDescription); - - return description.release ( ); -} -/*----------------------------------------------------------------------------*/ } // end namespace Geom /*----------------------------------------------------------------------------*/ } // end namespace Mgx3D diff --git a/src/Core/Geom/Vertex_Geom.cpp b/src/Core/Geom/Vertex_Geom.cpp index 8084d25d..dedc4892 100644 --- a/src/Core/Geom/Vertex_Geom.cpp +++ b/src/Core/Geom/Vertex_Geom.cpp @@ -5,7 +5,6 @@ #include "Geom/OCCHelper.h" #include "Group/Group0D.h" #include "Internal/Context.h" -#include "Topo/Vertex.h" /*----------------------------------------------------------------------------*/ #include #include @@ -53,36 +52,6 @@ GeomEntity* Vertex::clone(Internal::Context& c) Vertex::~Vertex() {} /*----------------------------------------------------------------------------*/ -Mgx3D::Utils::SerializedRepresentation* Vertex::getDescription (bool alsoComputed) const -{ - std::unique_ptr description ( - GeomEntity::getDescription (alsoComputed)); - CHECK_NULL_PTR_ERROR (description.get ( )) - std::vector coords; - coords.push_back (getX ( )); - coords.push_back (getY ( )); - coords.push_back (getZ ( )); - Mgx3D::Utils::SerializedRepresentation::Property coordsProp ( - "Coordonnées", coords); - Mgx3D::Utils::SerializedRepresentation propertyGeomDescription ( - "Propriété géométrique", coordsProp.getValue ( )); - propertyGeomDescription.addProperty (coordsProp); - -#ifdef _DEBUG // Issue#111 - // précision OpenCascade ou autre - TkUtil::UTF8String precStr (TkUtil::Charset::UTF_8); - precStr << BRep_Tool::Tolerance(m_occ_vertex);; - - propertyGeomDescription.addProperty ( - Utils::SerializedRepresentation::Property ("Précision", precStr.ascii()) ); -#endif // _DEBUG - - description->addPropertiesSet (propertyGeomDescription); - description->setSummary (coordsProp.getValue ( )); - - return description.release ( ); -} -/*----------------------------------------------------------------------------*/ std::string Vertex::getSummary ( ) const { std::vector coords; @@ -104,19 +73,6 @@ void Vertex::computeBoundingBox(Utils::Math::Point& pmin,Utils::Math::Point& pma OCCHelper::computeBoundingBox(m_occ_vertex, pmin, pmax); } /*----------------------------------------------------------------------------*/ -void Vertex::get(std::vector& vertices) -{ - const std::vector& topos = getRefTopo(); - - for (std::vector::const_iterator iter = topos.begin(); - iter != topos.end(); ++iter) - if ((*iter)->getDim() == 0){ - Topo::Vertex* vertex = dynamic_cast(*iter); - if (vertex) - vertices.push_back(vertex); - } -} -/*----------------------------------------------------------------------------*/ void Vertex::add(Curve* c) { m_curves.push_back(c); @@ -218,17 +174,6 @@ void Vertex::getGroups(std::vector& grp) const grp.insert(grp.end(), m_groups.begin(), m_groups.end()); } /*----------------------------------------------------------------------------*/ -void Vertex::setGroups(std::vector& grp) -{ - m_groups.clear(); - for (std::vector::iterator iter = grp.begin(); iter != grp.end(); iter++){ - Group::Group0D* g0 = dynamic_cast(*iter); - if (g0 == 0) - throw TkUtil::Exception (TkUtil::UTF8String ("Erreur interne avec conversion en groupe local dans setGroups", TkUtil::Charset::UTF_8)); - m_groups.push_back(g0); - } -} -/*----------------------------------------------------------------------------*/ int Vertex::getNbGroups() const { return m_groups.size(); diff --git a/src/Core/Geom/Volume_Geom.cpp b/src/Core/Geom/Volume_Geom.cpp index 7a14a56d..aa821050 100644 --- a/src/Core/Geom/Volume_Geom.cpp +++ b/src/Core/Geom/Volume_Geom.cpp @@ -6,7 +6,6 @@ #include "Geom/OCCHelper.h" #include "Group/Group3D.h" #include "Internal/Context.h" -#include "Topo/Block.h" /*----------------------------------------------------------------------------*/ #include #include @@ -151,17 +150,6 @@ void Volume::getGroups(std::vector& grp) const grp.insert(grp.end(), m_groups.begin(), m_groups.end()); } /*----------------------------------------------------------------------------*/ -void Volume::setGroups(std::vector& grp) -{ - m_groups.clear(); - for (std::vector::iterator iter = grp.begin(); iter != grp.end(); iter++){ - Group::Group3D* g3 = dynamic_cast(*iter); - if (g3 == 0) - throw TkUtil::Exception (TkUtil::UTF8String ("Erreur interne avec conversion en groupe local dans setGroups", TkUtil::Charset::UTF_8)); - m_groups.push_back(g3); - } -} -/*----------------------------------------------------------------------------*/ int Volume::getNbGroups() const { return m_groups.size(); @@ -184,44 +172,6 @@ void Volume::setDestroyed(bool b) Entity::setDestroyed(b); } /*----------------------------------------------------------------------------*/ -void Volume:: -get(std::vector& blocs) const -{ - const std::vector& topo_entities = getRefTopo(); - for (std::vector::const_iterator iter = topo_entities.begin(); - iter != topo_entities.end(); ++iter) - if ((*iter)->getDim() == 3) - blocs.push_back(dynamic_cast(*iter)); -} -/*----------------------------------------------------------------------------*/ -Utils::SerializedRepresentation* Volume::getDescription (bool alsoComputed) const -{ - std::unique_ptr description ( - GeomEntity::getDescription (alsoComputed)); - CHECK_NULL_PTR_ERROR (description.get ( )) - - Utils::SerializedRepresentation propertyGeomDescription ( - "Propriétés géométriques", ""); - - if (true == alsoComputed) - { - // récupération du volume - TkUtil::UTF8String volStr (TkUtil::Charset::UTF_8); - volStr<addDescription(propertyGeomDescription); - - - description->addPropertiesSet (propertyGeomDescription); - - return description.release ( ); -} -/*----------------------------------------------------------------------------*/ } // end namespace Geom /*----------------------------------------------------------------------------*/ } // end namespace Mgx3D diff --git a/src/Core/Group/Group0D.cpp b/src/Core/Group/Group0D.cpp index c52adb5a..5838e78f 100644 --- a/src/Core/Group/Group0D.cpp +++ b/src/Core/Group/Group0D.cpp @@ -36,16 +36,15 @@ TkUtil::UTF8String & operator << (TkUtil::UTF8String & o, const Group0D & g) o << " vide."; o << "\n"; - const std::vector& vtx = g.getVertices(); - for (std::vector::const_iterator iter1 = vtx.begin(); - iter1 != vtx.end(); ++iter1){ - const std::vector& topo = (*iter1)->getRefTopo(); - - o<<" "<<(*iter1)->getName()<<" ->"; - for (std::vector::const_iterator iter2 = topo.begin(); - iter2 != topo.end(); ++iter2) - o<<" "<<(*iter2)->getName(); - o << "\n"; + Topo::TopoManager& topo_manager = g.getContext().getTopoManager(); + for (Geom::Vertex* vtx : g.getVertices()) { + const std::vector& topos = topo_manager.getRefTopos(vtx); + if (topos.size() > 0) { + o<<" "<getName()<<" ->"; + for (Topo::TopoEntity* te : topos) + o<<" "<getName(); + o << "\n"; + } } return o; diff --git a/src/Core/Group/Group1D.cpp b/src/Core/Group/Group1D.cpp index ecaffd47..fc284736 100644 --- a/src/Core/Group/Group1D.cpp +++ b/src/Core/Group/Group1D.cpp @@ -35,16 +35,15 @@ TkUtil::UTF8String & operator << (TkUtil::UTF8String & o, const Group1D & g) o << " vide."; o << "\n"; - const std::vector& crv = g.getCurves(); - for (std::vector::const_iterator iter1 = crv.begin(); - iter1 != crv.end(); ++iter1){ - const std::vector& topo = (*iter1)->getRefTopo(); - - o<<" "<<(*iter1)->getName()<<" ->"; - for (std::vector::const_iterator iter2 = topo.begin(); - iter2 != topo.end(); ++iter2) - o<<" "<<(*iter2)->getName(); - o << "\n"; + Topo::TopoManager& topo_manager = g.getContext().getTopoManager(); + for (Geom::Curve* curv : g.getCurves()) { + const std::vector& topos = topo_manager.getRefTopos(curv); + if (topos.size() > 0) { + o<<" "<getName()<<" ->"; + for (Topo::TopoEntity* te : topos) + o<<" "<getName(); + o << "\n"; + } } return o; diff --git a/src/Core/Group/Group2D.cpp b/src/Core/Group/Group2D.cpp index e9d0662f..1e01c28d 100644 --- a/src/Core/Group/Group2D.cpp +++ b/src/Core/Group/Group2D.cpp @@ -37,16 +37,15 @@ TkUtil::UTF8String & operator << (TkUtil::UTF8String & o, const Group2D & g) o << " vide."; o << "\n"; - const std::vector& surf = g.getSurfaces(); - for (std::vector::const_iterator iter1 = surf.begin(); - iter1 != surf.end(); ++iter1){ - const std::vector& topo = (*iter1)->getRefTopo(); - - o<<" "<<(*iter1)->getName()<<" ->"; - for (std::vector::const_iterator iter2 = topo.begin(); - iter2 != topo.end(); ++iter2) - o<<" "<<(*iter2)->getName(); - o << "\n"; + Topo::TopoManager& topo_manager = g.getContext().getTopoManager(); + for (Geom::Surface* surf : g.getSurfaces()) { + const std::vector& topos = topo_manager.getRefTopos(surf); + if (topos.size() > 0) { + o<<" "<getName()<<" ->"; + for (Topo::TopoEntity* te : topos) + o<<" "<getName(); + o << "\n"; + } } return o; diff --git a/src/Core/Group/Group3D.cpp b/src/Core/Group/Group3D.cpp index 2cc72935..fe607651 100644 --- a/src/Core/Group/Group3D.cpp +++ b/src/Core/Group/Group3D.cpp @@ -38,16 +38,15 @@ TkUtil::UTF8String & operator << (TkUtil::UTF8String & o, const Group3D & g) o << " vide."; o << "\n"; - const std::vector& vol = g.getVolumes(); - for (std::vector::const_iterator iter1 = vol.begin(); - iter1 != vol.end(); ++iter1){ - const std::vector& topo = (*iter1)->getRefTopo(); - - o<<" "<<(*iter1)->getName()<<" ->"; - for (std::vector::const_iterator iter2 = topo.begin(); - iter2 != topo.end(); ++iter2) - o<<" "<<(*iter2)->getName(); - o << "\n"; + Topo::TopoManager& topo_manager = g.getContext().getTopoManager(); + for (Geom::Volume* vol : g.getVolumes()) { + const std::vector& topos = topo_manager.getRefTopos(vol); + if (topos.size() > 0) { + o<<" "<getName()<<" ->"; + for (Topo::TopoEntity* te : topos) + o<<" "<getName(); + o << "\n"; + } } return o; diff --git a/src/Core/Group/GroupManager.cpp b/src/Core/Group/GroupManager.cpp index f3ae3935..a52ef115 100644 --- a/src/Core/Group/GroupManager.cpp +++ b/src/Core/Group/GroupManager.cpp @@ -1283,17 +1283,10 @@ void GroupManager::addMark(Group3D* grp, // faut-il propager à la topologie ? if (visibilityMask >= Utils::FilterEntity::TopoBlock){ - const std::vector& topo = (vol)->getRefTopo(); - - for (std::vector::const_iterator iter2 = topo.begin(); - iter2 != topo.end(); ++iter2){ - if ((*iter2)->getDim() == 3){ - Topo::TopoEntity* te = *iter2; - Topo::Block* blk = dynamic_cast(te); - addMark(blk, visibilityMask, filtre_vu, filtre_topo, mark); - } - } - } // end if (visibilityMask >= Utils::FilterEntity::TopoBlock) + Topo::TopoManager& topo_manager = getContext().getTopoManager(); + for (Topo::Block* blk : topo_manager.getFilteredRefTopos(vol)) + addMark(blk, visibilityMask, filtre_vu, filtre_topo, mark); + } } // end if (filtre_vu[vol] == false) } @@ -1349,16 +1342,9 @@ void GroupManager::addMark(Group2D* grp, // faut-il propager à la topologie ? if (visibilityMask >= Utils::FilterEntity::TopoCoFace){ - const std::vector& topo = surf->getRefTopo(); - - for (std::vector::const_iterator iter2 = topo.begin(); - iter2 != topo.end(); ++iter2){ - if ((*iter2)->getDim() == 2){ - Topo::TopoEntity* te = *iter2; - Topo::CoFace* coface = dynamic_cast(te); - addMark(coface, visibilityMask, filtre_vu, filtre_topo, mark); - } - } + Topo::TopoManager& topo_manager = getContext().getTopoManager(); + for (Topo::CoFace* coface : topo_manager.getFilteredRefTopos(surf)) + addMark(coface, visibilityMask, filtre_vu, filtre_topo, mark); } // end if (visibilityMask >= Utils::FilterEntity::TopoCoFace) } // end if (filtre_vu[surf] == false) @@ -1399,16 +1385,9 @@ void GroupManager::addMark(Group1D* grp, // faut-il propager à la topologie ? if (visibilityMask >= Utils::FilterEntity::TopoCoEdge){ - const std::vector& topo = c->getRefTopo(); - - for (std::vector::const_iterator iter2 = topo.begin(); - iter2 != topo.end(); ++iter2){ - if ((*iter2)->getDim() == 1){ - Topo::TopoEntity* te = *iter2; - Topo::CoEdge* coedge = dynamic_cast(te); - addMark(coedge, visibilityMask, filtre_vu, filtre_topo, mark); - } - } + Topo::TopoManager& topo_manager = getContext().getTopoManager(); + for (Topo::CoEdge* coedge : topo_manager.getFilteredRefTopos(c)) + addMark(coedge, visibilityMask, filtre_vu, filtre_topo, mark); } // end if (visibilityMask >= Utils::FilterEntity::TopoCoEdge) } // end if (filtre_vu[c] == false) @@ -1441,16 +1420,9 @@ void GroupManager::addMark(Group0D* grp, // faut-il propager à la topologie ? if (visibilityMask >= Utils::FilterEntity::TopoVertex){ - const std::vector& topo = vert->getRefTopo(); - - for (std::vector::const_iterator iter2 = topo.begin(); - iter2 != topo.end(); ++iter2){ - if ((*iter2)->getDim() == 0){ - Topo::TopoEntity* te = *iter2; - Topo::Vertex* vertex = dynamic_cast(te); - addMark(vertex, visibilityMask, filtre_vu, filtre_topo, mark); - } - } + Topo::TopoManager& topo_manager = getContext().getTopoManager(); + for (Topo::Vertex* vertex : topo_manager.getFilteredRefTopos(vert)) + addMark(vertex, visibilityMask, filtre_vu, filtre_topo, mark); } // end if (visibilityMask >= Utils::FilterEntity::TopoVertex) } // end if (filtre_vu[vert] == false) diff --git a/src/Core/Internal/EntitiesHelper.cpp b/src/Core/Internal/EntitiesHelper.cpp index 05ff0ab7..e370f53b 100644 --- a/src/Core/Internal/EntitiesHelper.cpp +++ b/src/Core/Internal/EntitiesHelper.cpp @@ -228,23 +228,6 @@ std::string EntitiesHelper::entitiesNames ( return names.iso ( ); } // EntitiesHelper::entitiesNames /*----------------------------------------------------------------------------*/ -bool EntitiesHelper::hasTopoRef(std::vector& entities) -{ - for (uint i=0; igetRefTopo().empty()) - return true; - - Geom::GetDownIncidentGeomEntitiesVisitor v; - entities[i]->accept(v); - for (auto sub_entity : v.get()) - if (!sub_entity->getRefTopo().empty()) - return true; - - } // end for i EntitiesHelper::replaceNameByCommandRef(std::vector& commands) { std::vector scripts; diff --git a/src/Core/Internal/InfoCommand.cpp b/src/Core/Internal/InfoCommand.cpp index e30cf6a2..fd8701aa 100644 --- a/src/Core/Internal/InfoCommand.cpp +++ b/src/Core/Internal/InfoCommand.cpp @@ -217,12 +217,15 @@ void InfoCommand::addGroupInfoEntity(Group::GroupEntity* entity, type t) TkUtil::AutoMutex autoMutex (&m_mutex); #ifdef _DEBUG2 std::cout<<"addGroupInfoEntity("<getName()<<" (id "<getUniqueId()<<")," - < "< "< "<& topos = surf->getRefTopo(); + Topo::TopoManager& tm = m_context.getTopoManager(); + const std::vector& topos = tm.getRefTopos(surf); if (topos.size() > 1){ // il faut récupérer les différentes cofaces qui pointent sur cette surface @@ -263,7 +264,8 @@ Topo::CoFace* ServiceGeomToTopo::getCoFace(Geom::Surface* surf) return 0; // utilisation si possible d'une topologie s'il y en a une - const std::vector& topos = surf->getRefTopo(); + Topo::TopoManager& tm = m_context.getTopoManager(); + const std::vector& topos = tm.getRefTopos(surf); if (topos.size() > 1){ throw TkUtil::Exception(TkUtil::UTF8String ("Erreur, la surface possède déjà une topologie composée de plusieurs entités topologiques", TkUtil::Charset::UTF_8)); @@ -337,10 +339,10 @@ std::vector ServiceGeomToTopo::getEdges(std::vector& filtre_coedges[coedges[i]] = 1; Topo::Vertex* first_vertex = 0; + Topo::TopoManager& tm = m_context.getTopoManager(); for (uint i=0; i topos; - vtx->getRefTopo(topos); + const std::vector& topos = tm.getRefTopos(vtx); if (topos.size() == 1){ if (topos[0]->getType() == Utils::Entity::TopoVertex){ Topo::Vertex* vertex = dynamic_cast(topos[0]); @@ -408,7 +410,8 @@ Topo::Edge* ServiceGeomToTopo::getEdge(Geom::Curve* curve) // utilisation si possible d'une topologie s'il y en a une - const std::vector& topos = curve->getRefTopo(); + Topo::TopoManager& tm = m_context.getTopoManager(); + const std::vector& topos = tm.getRefTopos(curve); if (topos.size() > 1){ // il faut récupérer les différentes coedges qui pointent sur cette courbe @@ -488,7 +491,8 @@ Topo::Edge* ServiceGeomToTopo::getEdge(Geom::Curve* curve) Topo::CoEdge* ServiceGeomToTopo::getCoEdge(Geom::Curve* curve) { Topo::CoEdge* coedge = 0; - const std::vector& topos = curve->getRefTopo(); + Topo::TopoManager& tm = m_context.getTopoManager(); + const std::vector& topos = tm.getRefTopos(curve); if (topos.size() == 1){ Topo::TopoEntity* te = topos[0]; if (te->getDim() != 1) @@ -511,7 +515,8 @@ Topo::Vertex* ServiceGeomToTopo::getVertex(Geom::Vertex* gv) if (tv == 0){ // utilisation si possible d'une topologie s'il y en a une - const std::vector& topos = gv->getRefTopo(); + Topo::TopoManager& tm = m_context.getTopoManager(); + const std::vector& topos = tm.getRefTopos(gv); if (topos.size() > 1) throw TkUtil::Exception(TkUtil::UTF8String ("Erreur interne, plusieurs entités topologiques pointent sur un sommet géométrique", TkUtil::Charset::UTF_8)); else if (topos.size() == 1){ diff --git a/src/Core/Mesh/CommandAddRemoveGroupName.cpp b/src/Core/Mesh/CommandAddRemoveGroupName.cpp index b08cb7e6..ccb4e60f 100644 --- a/src/Core/Mesh/CommandAddRemoveGroupName.cpp +++ b/src/Core/Mesh/CommandAddRemoveGroupName.cpp @@ -614,9 +614,9 @@ void CommandAddRemoveGroupName:: updateMesh(Geom::Volume* vol, std::string grpName, bool add) { // récupération de la liste des blocs - std::vector blocs; - vol->get(blocs); - updateMesh(blocs, grpName, add); + Topo::TopoManager& tm = getContext().getTopoManager(); + std::vector blocs = tm.getFilteredRefTopos(vol); + updateMesh(blocs, grpName, add); } /*----------------------------------------------------------------------------*/ void CommandAddRemoveGroupName:: @@ -628,9 +628,8 @@ updateMesh(std::vector& blocs, std::string grpName, bool add) // recherche si l'un d'entre eux est maillé bool is_meshed = false; - for (std::vector::iterator iter = blocs.begin(); - iter != blocs.end(); ++iter){ - if ((*iter)->isMeshed()) + for (Topo::Block* blk : blocs){ + if (blk->isMeshed()) is_meshed = true; } @@ -655,20 +654,19 @@ updateMesh(std::vector& blocs, std::string grpName, bool add) } Mesh::Volume* mvol = getContext().getMeshManager().getVolume(grpName); - for (std::vector::iterator iter = blocs.begin(); - iter != blocs.end(); ++iter) - if ((*iter)->isMeshed()){ + for (Topo::Block* blk : blocs) + if (blk->isMeshed()){ if (add){ #ifdef _DEBUG_UPDATE std::cout<<" "<getName()<<" addBlock("<<(*iter)->getName()<<")"<addBlock(*iter); + mvol->addBlock(blk); } else { #ifdef _DEBUG_UPDATE std::cout<<" "<getName()<<" removeBlock("<<(*iter)->getName()<<")"<removeBlock(*iter); + mvol->removeBlock(blk); } } if (isNewVolume) @@ -683,8 +681,8 @@ void CommandAddRemoveGroupName:: updateMesh(Geom::Surface* surf, std::string grpName, bool add) { // récupération de la liste des CoFaces - std::vector cofaces; - surf->get(cofaces); + Topo::TopoManager& tm = getContext().getTopoManager(); + std::vector cofaces = tm.getFilteredRefTopos(surf); updateMesh(cofaces, grpName, add); } /*----------------------------------------------------------------------------*/ @@ -748,9 +746,9 @@ void CommandAddRemoveGroupName:: updateMesh(Geom::Curve* crv, std::string grpName, bool add) { // récupération de la liste des CoEdges - std::vector coedges; - crv->get(coedges); - updateMesh(coedges, grpName, add); + Topo::TopoManager& tm = getContext().getTopoManager(); + std::vector coedges = tm.getFilteredRefTopos(crv); + updateMesh(coedges, grpName, add); } /*----------------------------------------------------------------------------*/ void CommandAddRemoveGroupName:: diff --git a/src/Core/Mesh/CommandClearGroupName.cpp b/src/Core/Mesh/CommandClearGroupName.cpp index 2162999f..a9731802 100644 --- a/src/Core/Mesh/CommandClearGroupName.cpp +++ b/src/Core/Mesh/CommandClearGroupName.cpp @@ -183,6 +183,15 @@ void CommandClearGroupName::internalExecute() /*----------------------------------------------------------------------------*/ void CommandClearGroupName::internalUndo() { + + getInfoCommand().permCreatedDeleted(); + + // suppression de ce qui a été ajouté + deleteCreatedMeshEntities(); + + // permute toutes les propriétés internes avec leur sauvegarde + permInternalsStats(); + Group::GroupManager& gm = getContext().getGroupManager(); std::string default_group_name = gm.getDefaultName(m_dim); @@ -268,7 +277,10 @@ void CommandClearGroupName::internalUndo() } break; } - +} +/*----------------------------------------------------------------------------*/ +void CommandClearGroupName::internalRedo() +{ getInfoCommand().permCreatedDeleted(); // suppression de ce qui a été ajouté @@ -276,10 +288,7 @@ void CommandClearGroupName::internalUndo() // permute toutes les propriétés internes avec leur sauvegarde permInternalsStats(); -} -/*----------------------------------------------------------------------------*/ -void CommandClearGroupName::internalRedo() -{ + switch(m_dim){ case(0):{ for (std::vector::iterator iter = m_geom_entities.begin(); @@ -360,23 +369,15 @@ void CommandClearGroupName::internalRedo() } break; } - - getInfoCommand().permCreatedDeleted(); - - // suppression de ce qui a été ajouté - deleteCreatedMeshEntities(); - - // permute toutes les propriétés internes avec leur sauvegarde - permInternalsStats(); } /*----------------------------------------------------------------------------*/ void CommandClearGroupName:: updateMesh(Geom::Volume* vol, std::string grpName, bool add) { // récupération de la liste des blocs - std::vector blocs; - vol->get(blocs); - updateMesh(blocs, grpName, add); + Topo::TopoManager& tm = getContext().getTopoManager(); + std::vector blocs = tm.getFilteredRefTopos(vol); + updateMesh(blocs, grpName, add); } /*----------------------------------------------------------------------------*/ void CommandClearGroupName:: @@ -443,8 +444,8 @@ void CommandClearGroupName:: updateMesh(Geom::Surface* surf, std::string grpName, bool add) { // récupération de la liste des CoFaces - std::vector cofaces; - surf->get(cofaces); + Topo::TopoManager& tm = getContext().getTopoManager(); + std::vector cofaces = tm.getFilteredRefTopos(surf); updateMesh(cofaces, grpName, add); } /*----------------------------------------------------------------------------*/ @@ -508,9 +509,9 @@ void CommandClearGroupName:: updateMesh(Geom::Curve* crv, std::string grpName, bool add) { // récupération de la liste des CoEdges - std::vector coedges; - crv->get(coedges); - updateMesh(coedges, grpName, add); + Topo::TopoManager& tm = getContext().getTopoManager(); + std::vector coedges = tm.getFilteredRefTopos(crv); + updateMesh(coedges, grpName, add); } /*----------------------------------------------------------------------------*/ void CommandClearGroupName:: diff --git a/src/Core/Mesh/CommandCreateMesh.cpp b/src/Core/Mesh/CommandCreateMesh.cpp index 824f2ea7..51679e26 100644 --- a/src/Core/Mesh/CommandCreateMesh.cpp +++ b/src/Core/Mesh/CommandCreateMesh.cpp @@ -1038,20 +1038,18 @@ meshAndModify(std::list& list_cofaces) } // application de la modif pour chacun des groupes 2D + Topo::TopoManager& tm = getContext().getTopoManager(); for (std::list::iterator iter1 = list_grp.begin(); iter1 != list_grp.end(); ++iter1){ Group::Group2D* grp = *iter1; // liste des cofaces associé au groupe - std::list cofaces_grp; - std::vector surfaces = grp->getSurfaces(); - for (std::vector::iterator iter2 = surfaces.begin(); - iter2 != surfaces.end(); ++iter2){ - std::vector cofaces; - (*iter2)->get(cofaces); + std::list cofaces_grp; + for (Geom::Surface* surf : surfaces) { + std::vector cofaces = tm.getFilteredRefTopos(surf); cofaces_grp.insert(cofaces_grp.end(), cofaces.begin(), cofaces.end()); - } // end for iter2 + } // end for surf std::vector& cofaces = grp->getCoFaces(); cofaces_grp.insert(cofaces_grp.end(), cofaces.begin(), cofaces.end()); @@ -1155,13 +1153,9 @@ meshAndModify(std::list& list_cofaces) } else if (lissageSurf){ - // le lissage dépend de la surface sur laquelle se fait la projection - for (std::vector::iterator iter2 = surfaces.begin(); - iter2 != surfaces.end(); ++iter2){ - Geom::Surface* surface = *iter2; - std::vector cofaces; - surface->get(cofaces); + for (Geom::Surface* surface : surfaces){ + std::vector cofaces = tm.getFilteredRefTopos(surface); // marque par coface pour savoir si elle est dans le même sens (normale) que les autres std::map isCoFaceInverted; @@ -1171,9 +1165,7 @@ meshAndModify(std::list& list_cofaces) // ensemble des cofaces d'une surface du groupe qui sont maillées à la fin std::vector meshed_cofaces; - for (std::vector::iterator iter3 = cofaces.begin(); - iter3 != cofaces.end(); ++iter3){ - Topo::CoFace* coface = *iter3; + for (Topo::CoFace* coface : cofaces) { if (coface->isMeshed()) meshed_cofaces.push_back(coface); } // end for iter3 @@ -1188,9 +1180,7 @@ meshAndModify(std::list& list_cofaces) // 2 pour les noeuds au bord d'une surface de maillage std::map filtre_nodes_lisse; - for (std::vector::iterator iter3 = meshed_cofaces.begin(); - iter3 != meshed_cofaces.end(); ++iter3){ - Topo::CoFace* coface = *iter3; + for (Topo::CoFace* coface : meshed_cofaces){ bool isInverted = isCoFaceInverted[coface]; std::vector& l_nds = coface->nodes(); std::vector& l_poly = coface->faces(); @@ -1238,7 +1228,7 @@ meshAndModify(std::list& list_cofaces) // applique le lissage uniquement aux noeuds internes à la surface (non marqués à 2) lissageSurf->applyModification(nodes, polygones, filtre_nodes_lisse, isPolyInverted, 2, surface); - } // end for iter2 + } // end for surface } @@ -1255,10 +1245,7 @@ modify(std::vector& list_blocks) // recherche des groupes 3D, parmis les blocs en entrée, qui ont une modification std::list list_grp; - for (std::vector::iterator iter1 = list_blocks.begin(); - iter1 != list_blocks.end(); ++iter1){ - Topo::Block* block = *iter1; - + for (Topo::Block* block : list_blocks){ if (block->getGeomAssociation() && block->getGeomAssociation()->getDim() == 3){ Geom::Volume* volume = dynamic_cast(block->getGeomAssociation()); CHECK_NULL_PTR_ERROR(volume); @@ -1276,8 +1263,7 @@ modify(std::vector& list_blocks) } // les groupes depuis les blocs - std::vector grps = block->getGroups(); - for (Group::Group3D* grp : grps){ + for (Group::Group3D* grp : block->getGroups()){ if (grp->getNbMeshModif() != 0) list_grp.push_back(grp); } @@ -1291,7 +1277,7 @@ modify(std::vector& list_blocks) #endif gmds::Mesh& gmds_mesh = getMeshManager().getMesh()->getGMDSMesh(); - + Topo::TopoManager& tm = getContext().getTopoManager(); // application de la modif pour chacun des groupes 3D for (std::list::iterator iter1 = list_grp.begin(); iter1 != list_grp.end(); ++iter1){ @@ -1301,20 +1287,15 @@ modify(std::vector& list_blocks) std::list blocks_grp; std::vector volumes = grp->getVolumes(); - for (std::vector::iterator iter2 = volumes.begin(); - iter2 != volumes.end(); ++iter2){ - std::vector blocks; - (*iter2)->get(blocks); + for (Geom::Volume* vol : volumes){ + std::vector blocks = tm.getFilteredRefTopos(vol); blocks_grp.insert(blocks_grp.end(), blocks.begin(), blocks.end()); } // end for iter2 blocks_grp.sort(Utils::Entity::compareEntity); blocks_grp.unique(); - for (std::list::iterator iter2 = blocks_grp.begin(); - iter2 != blocks_grp.end(); ++iter2){ - Topo::Block* block = *iter2; - + for (Topo::Block* block : blocks_grp){ if (!block->isMeshed()){ TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8); messErr <<"Le bloc "<getName()<<" n'est pas maillé ce qui pose problème pour permettre la perturbation sur le groupe.\n"; @@ -1336,18 +1317,13 @@ modify(std::vector& list_blocks) if (lissageVol){ // le lissage dépend du volume sur lequel se fait la projection - for (std::vector::iterator iter2 = volumes.begin(); - iter2 != volumes.end(); ++iter2){ - Geom::Volume* volume = *iter2; - std::vector blocks; - volume->get(blocks); + for (Geom::Volume* volume : volumes){ + std::vector blocks = tm.getFilteredRefTopos(volume); // ensemble des blocs d'un volume du groupe qui sont maillés à la fin std::vector meshed_blocks; - for (std::vector::iterator iter3 = blocks.begin(); - iter3 != blocks.end(); ++iter3){ - Topo::Block* block = *iter3; + for (Topo::Block* block : blocks){ if (block->isMeshed()) meshed_blocks.push_back(block); } // end for iter3 @@ -1362,17 +1338,14 @@ modify(std::vector& list_blocks) // 2 pour les noeuds au bord d'un volume de maillage std::map filtre_nodes_lisse; - for (std::vector::iterator iter3 = meshed_blocks.begin(); - iter3 != meshed_blocks.end(); ++iter3){ - Topo::Block* block = *iter3; + for (Topo::Block* block : blocks){ std::vector& l_nds = block->nodes(); std::vector& l_poly = block->regions(); for(unsigned int i_poly=0;i_poly(l_poly[i_poly])); + polygedres.push_back(gmds_mesh.get(l_poly[i_poly])); } - for (std::vector::iterator iter4 = l_nds.begin(); iter4 != l_nds.end(); ++iter4) if (filtre_nodes_lisse[*iter4] == 0){ @@ -1386,19 +1359,16 @@ modify(std::vector& list_blocks) border_meshed_cofaces = Topo::TopoHelper::getBorder(meshed_blocks); // on marque les noeuds des arêtes au bord à 2 pour ne pas les déplacer - for (std::vector::iterator iter3 = border_meshed_cofaces.begin(); - iter3 != border_meshed_cofaces.end(); ++iter3){ - std::vector& nodes = (*iter3)->nodes(); + for (Topo::CoFace* coface : border_meshed_cofaces){ + std::vector& nodes = coface->nodes(); for (std::vector::iterator iter4 = nodes.begin(); iter4 != nodes.end(); ++iter4) filtre_nodes_lisse[*iter4] = 2; - } // end for iter3 + } // applique le lissage uniquement aux noeuds internes au volume (non marqués à 2) lissageVol->applyModification(nodes, polygedres, filtre_nodes_lisse, 2, volume); - - } // end for iter2 - + } // end for volume } else if (pert){ diff --git a/src/Core/Mesh/CommandMeshExplorer.cpp b/src/Core/Mesh/CommandMeshExplorer.cpp index 994a0382..cfe2e572 100644 --- a/src/Core/Mesh/CommandMeshExplorer.cpp +++ b/src/Core/Mesh/CommandMeshExplorer.cpp @@ -156,37 +156,30 @@ selectCoFaceAndBlocks(std::map& filtre_coface, // le nombre de blocs maillés en structuré uint nb_blocks_marked = 0; + Topo::TopoManager& tm = getContext().getTopoManager(); for (uint ig=0; ig& volumes = grp[ig]->getVolumes(); for (uint i=0; i topos = volumes[i]->getRefTopo(); - for (uint j=0; jgetDim() == 3){ - Topo::TopoEntity* te = topos[j]; - Topo::Block* blk = dynamic_cast(te); - if (blk == 0) - throw TkUtil::Exception (TkUtil::UTF8String ("CommandMeshExplorer a échoué pour récupérer un bloc", TkUtil::Charset::UTF_8)); - - if (blk->isStructured()){ // && blk->isMeshed() - filtre_block[blk] = 1; - nb_blocks_marked += 1; + std::vector topos = tm.getFilteredRefTopos(volumes[i]); + for (Topo::Block* blk : topos) { + if (blk->isStructured()){ // && blk->isMeshed() + filtre_block[blk] = 1; + nb_blocks_marked += 1; #ifdef _DEBUG_EXPLORER - std::cout<<" bloc pris en compte : "<getName()<getName()< cofaces; + std::vector cofaces; - blk->getCoFaces(cofaces); + blk->getCoFaces(cofaces); - for (std::vector::iterator iter1 = cofaces.begin(); - iter1 != cofaces.end(); ++iter1){ - filtre_coface[*iter1] = 1; - //std::cout<<"filtre_coface à 1 pour "<<(*iter1)->getName()<getName()<isStructured() && blk->isMeshed()) - } // end if (topos[j]->getDim() == 3) - } // end for j + } // end if (blk->isStructured() && blk->isMeshed()) + } // end for blk : topos } // end for i std::vector& blocks = grp[ig]->getBlocks(); diff --git a/src/Core/Services/DescriptionService.cpp b/src/Core/Services/DescriptionService.cpp new file mode 100644 index 00000000..b780065d --- /dev/null +++ b/src/Core/Services/DescriptionService.cpp @@ -0,0 +1,346 @@ +#include "Services/DescriptionService.h" +#include "Utils/SerializedRepresentation.h" +#include "Internal/Context.h" +#include "Geom/IncidentGeomEntitiesVisitor.h" +#include "Topo/TopoManager.h" +#include "Topo/Vertex.h" +#include "Topo/CoEdge.h" +#include "Topo/CoFace.h" +#include "Topo/Block.h" +#include "Group/Group0D.h" +#include "Group/Group1D.h" +#include "Group/Group2D.h" +#include "Group/Group3D.h" +#include +#include +#include + +using Property = Mgx3D::Utils::SerializedRepresentation::Property; + +namespace Mgx3D::Services +{ + Utils::SerializedRepresentation *DescriptionService::getDescription(const Geom::GeomEntity *e, const bool alsoComputed) + { + DescriptionService ds(alsoComputed); + e->accept(ds); + return ds.m_representation; + } + + DescriptionService::DescriptionService(const bool alsoComputed) + : m_also_computed(alsoComputed), m_representation(nullptr) + { + } + + void DescriptionService::visit(const Geom::Vertex *e) + { + visitGeomEntity(e); + std::vector coords; + coords.push_back(e->getX()); + coords.push_back(e->getY()); + coords.push_back(e->getZ()); + Property coordsProp("Coordonnées", coords); + Utils::SerializedRepresentation propertyGeomDescription("Propriété géométrique", coordsProp.getValue()); + propertyGeomDescription.addProperty(coordsProp); + +#ifdef _DEBUG // Issue#111 + // précision OpenCascade ou autre + TkUtil::UTF8String precStr(TkUtil::Charset::UTF_8); + precStr << BRep_Tool::Tolerance(e->getOCCVertex()); + + propertyGeomDescription.addProperty(Property("Précision", precStr.ascii())); +#endif // _DEBUG + + m_representation->addPropertiesSet(propertyGeomDescription); + m_representation->setSummary(coordsProp.getValue()); + } + + void DescriptionService::visit(const Geom::Curve *e) + { + visitGeomEntity(e); + Utils::SerializedRepresentation propertyGeomDescription("Propriétés géométriques", ""); + + if (true == m_also_computed) + { + // recuperation de la longueur + TkUtil::UTF8String volStr(TkUtil::Charset::UTF_8); + volStr << e->getArea(); + propertyGeomDescription.addProperty(Property("Longueur", volStr.ascii())); + } + + auto occ_edges = e->getOCCEdges(); +#ifdef _DEBUG // Issue#111 + // précision OpenCascade + for (uint i = 0; i < occ_edges.size(); i++) + { + TkUtil::UTF8String precStr(TkUtil::Charset::UTF_8); + precStr << BRep_Tool::Tolerance(occ_edges[i]); + propertyGeomDescription.addProperty(Property("Précision", precStr.ascii())); + } +#endif // _DEBUG + + // on ajoute des infos du style: c'est une droite, un arc de cercle, une ellipse, une b-spline + TkUtil::UTF8String typeStr(TkUtil::Charset::UTF_8); + bool isABSpline = false; + if (e->isLinear()) + typeStr << "segment"; + else if (e->isCircle()) + typeStr << "cercle"; + else if (e->isEllipse()) + typeStr << "ellipse"; + else if (e->isBSpline()) + { + isABSpline = true; + typeStr << "b-spline"; + } + else if (occ_edges.size() > 1) + typeStr << "composée"; + else + typeStr << "quelconque"; + + propertyGeomDescription.addProperty(Property("Type", typeStr)); + +#ifdef _DEBUG + if (isABSpline) + { + TkUtil::UTF8String nbStr1(TkUtil::Charset::UTF_8); + TkUtil::UTF8String nbStr2(TkUtil::Charset::UTF_8); + + // c'est une spline => une seule représentation de type Edge + TopoDS_Edge edge = occ_edges[0]; + Standard_Real first_param, last_param; + Handle_Geom_Curve curve = BRep_Tool::Curve(edge, first_param, last_param); + + Handle(Geom_BSplineCurve) bspline = Handle(Geom_BSplineCurve)::DownCast(curve); + + nbStr1 << (long int)bspline->NbKnots(); + nbStr2 << (long int)bspline->NbPoles(); + + propertyGeomDescription.addProperty( + Property("Nb noeuds", nbStr1.ascii())); + propertyGeomDescription.addProperty( + Property("Nb poles", nbStr2.ascii())); + } + + // affichage des paramètres extrémas + double first, last; + e->getParameters(first, last); + TkUtil::UTF8String param1(TkUtil::Charset::UTF_8); + param1 << first; + TkUtil::UTF8String param2(TkUtil::Charset::UTF_8); + param2 << last; + propertyGeomDescription.addProperty(Property("Param first", param1.ascii())); + propertyGeomDescription.addProperty(Property("Param last", param2.ascii())); +#endif + + m_representation->addPropertiesSet(propertyGeomDescription); + } + + void DescriptionService::visit(const Geom::Surface *e) + { + visitGeomEntity(e); + Utils::SerializedRepresentation propertyGeomDescription("Propriétés géométriques", ""); + + if (true == m_also_computed) + { + // recuperation de l'aire + TkUtil::UTF8String volStr(TkUtil::Charset::UTF_8); + volStr << e->getArea(); + propertyGeomDescription.addProperty(Property("Aire", volStr.ascii())); + } + + auto occ_faces = e->getOCCFaces(); +#ifdef _DEBUG // Issue#111 + // précision OpenCascade ou autre + for (uint i = 0; i < occ_faces.size(); i++) + { + TkUtil::UTF8String precStr(TkUtil::Charset::UTF_8); + precStr << BRep_Tool::Tolerance(occ_faces[i]); + propertyGeomDescription.addProperty(Property("Précision", precStr.ascii())); + } +#endif // _DEBUG + + // on ajoute des infos du style: c'est un plan + TkUtil::UTF8String typeStr(TkUtil::Charset::UTF_8); + if (e->isPlanar()) + typeStr << "plan"; + else if (occ_faces.size() > 1) + typeStr << "composée"; + else + typeStr << "quelconque"; + + propertyGeomDescription.addProperty(Property("Type", typeStr.ascii())); + m_representation->addPropertiesSet(propertyGeomDescription); + } + + void DescriptionService::visit(const Geom::Volume *e) + { + visitGeomEntity(e); + Utils::SerializedRepresentation propertyGeomDescription("Propriétés géométriques", ""); + + if (true == m_also_computed) + { + // récupération du volume + TkUtil::UTF8String volStr(TkUtil::Charset::UTF_8); + volStr << e->getArea(); + propertyGeomDescription.addProperty(Property("Volume", volStr.ascii())); + } + + // pour afficher les spécifictés de certaines propriétés + e->getGeomProperty()->addDescription(propertyGeomDescription); + m_representation->addPropertiesSet(propertyGeomDescription); + } + + void DescriptionService::visitEntity(const Utils::Entity *e) + { + m_representation = e->Utils::Entity::getDescription(m_also_computed); + } + + void DescriptionService::visitGeomEntity(const Geom::GeomEntity *e) + { + visitEntity(e); + Utils::SerializedRepresentation relationsGeomDescription("Relations géométriques", ""); + Geom::GetUpIncidentGeomEntitiesVisitor vup; + Geom::GetDownIncidentGeomEntitiesVisitor vdown; + Geom::GetAdjacentGeomEntitiesVisitor vadj; + e->accept(vup); + e->accept(vdown); + e->accept(vadj); + + // On y ajoute les éléments géométriques en relation avec celui-ci : + auto v = vdown.getVertices(); + v.insert(vadj.getVertices().begin(), vadj.getVertices().end()); + buildSerializedRepresentation(relationsGeomDescription, "Sommets", v); + TkUtil::UTF8String summary(TkUtil::Charset::UTF_8); + for (auto vert : v) + summary << vert->getName() << " "; + m_representation->setSummary(summary.ascii()); + + auto c = vup.getCurves(); + c.insert(vdown.getCurves().begin(), vdown.getCurves().end()); + c.insert(vadj.getCurves().begin(), vadj.getCurves().end()); + buildSerializedRepresentation(relationsGeomDescription, "Courbes", c); + + auto s = vup.getSurfaces(); + s.insert(vdown.getSurfaces().begin(), vdown.getSurfaces().end()); + s.insert(vadj.getSurfaces().begin(), vadj.getSurfaces().end()); + buildSerializedRepresentation(relationsGeomDescription, "Surfaces", s); + + auto vol = vup.getVolumes(); + vol.insert(vadj.getVolumes().begin(), vadj.getVolumes().end()); + buildSerializedRepresentation(relationsGeomDescription, "Volumes", vol); + + m_representation->addPropertiesSet(relationsGeomDescription); + + // la Topologie s'il y en a une + Topo::TopoManager& tm = e->getContext().getTopoManager(); + std::vector topo_entities = tm.getRefTopos(e); + if (topo_entities.size() > 0) + { + Utils::SerializedRepresentation topoDescription("Relations topologiques", ""); + + std::vector vertices; + std::vector coedges; + std::vector cofaces; + std::vector blocks; + + for (Topo::TopoEntity *topo : topo_entities) + { + if (topo->getDim() == 0) + vertices.push_back(dynamic_cast(topo)); + else if (topo->getDim() == 1) + coedges.push_back(dynamic_cast(topo)); + else if (topo->getDim() == 2) + cofaces.push_back(dynamic_cast(topo)); + else if (topo->getDim() == 3) + blocks.push_back(dynamic_cast(topo)); + } + + buildSerializedRepresentation(topoDescription, "Sommets topologiques", vertices); + buildSerializedRepresentation(topoDescription, "Arêtes topologiques", coedges); + buildSerializedRepresentation(topoDescription, "Faces topologiques", cofaces); + buildSerializedRepresentation(topoDescription, "Blocs topologiques", blocks); + + m_representation->addPropertiesSet(topoDescription); + } + else + { + m_representation->addProperty(Property("Relations topologiques", std::string("Aucune"))); + } + + // Les groupes s'il y en a + std::vector groups; + e->getGroups(groups); + if (!groups.empty()) + { + Utils::SerializedRepresentation groupeDescription("Relations vers des groupes", ""); + + std::vector g0; + std::vector g1; + std::vector g2; + std::vector g3; + + for (Group::GroupEntity *grp : groups) + { + if (grp->getDim() == 0) + g0.push_back(dynamic_cast(grp)); + else if (grp->getDim() == 1) + g1.push_back(dynamic_cast(grp)); + else if (grp->getDim() == 2) + g2.push_back(dynamic_cast(grp)); + else if (grp->getDim() == 3) + g3.push_back(dynamic_cast(grp)); + } + + buildSerializedRepresentation(groupeDescription, "Groupes 0D", g0); + buildSerializedRepresentation(groupeDescription, "Groupes 1D", g1); + buildSerializedRepresentation(groupeDescription, "Groupes 2D", g2); + buildSerializedRepresentation(groupeDescription, "Groupes 3D", g3); + + m_representation->addPropertiesSet(groupeDescription); + groupeDescription.setSummary(TkUtil::NumericConversions::toStr(groups.size())); + } + else + { + m_representation->addProperty(Property("Relations vers des groupes", std::string("Aucune"))); + } +#ifdef _DEBUG + Utils::SerializedRepresentation occGeomDescription("Propriétés OCC", ""); + // observation du HashCode retourné par OCC + + auto add_description = [&](const TopoDS_Shape &sh) + { + int hc = sh.HashCode(INT_MAX); + occGeomDescription.addProperty(Property("HashCode", (long int)hc)); + }; + e->apply(add_description); + m_representation->addPropertiesSet(occGeomDescription); +#endif + } + + template + void DescriptionService:: + buildSerializedRepresentation(Utils::SerializedRepresentation &description, const std::string &title, const Utils::EntitySet elements) const + { + if (!elements.empty()) + { + Utils::SerializedRepresentation sr(title, TkUtil::NumericConversions::toStr(elements.size())); + for (auto elt : elements) + sr.addProperty(Property(elt->getName(), *elt)); + description.addPropertiesSet(sr); + } + } + + template + void DescriptionService:: + buildSerializedRepresentation(Utils::SerializedRepresentation &description, const std::string &title, const std::vector elements) const + { + if (!elements.empty()) + { + Utils::SerializedRepresentation sr(title, TkUtil::NumericConversions::toStr(elements.size())); + for (auto elt : elements) + sr.addProperty(Property(elt->getName(), *elt)); + description.addPropertiesSet(sr); + } + } + +} diff --git a/src/Core/Services/InfoService.cpp b/src/Core/Services/InfoService.cpp new file mode 100644 index 00000000..e6fd4647 --- /dev/null +++ b/src/Core/Services/InfoService.cpp @@ -0,0 +1,55 @@ +#include "Services/InfoService.h" +#include "Internal/Context.h" +#include "Geom/GeomEntity.h" +#include "Geom/IncidentGeomEntitiesVisitor.h" +#include "Topo/TopoEntity.h" + +namespace Mgx3D::Services +{ + Geom::GeomInfo InfoService::getInfos(const Geom::GeomEntity* e) + { + Geom::GeomInfo info; + info.name = e->getName(); + info.dimension = e->getDim(); + info.area = e->computeArea(); + + Geom::GetUpIncidentGeomEntitiesVisitor vup; + Geom::GetDownIncidentGeomEntitiesVisitor vdown; + Geom::GetAdjacentGeomEntitiesVisitor vadj; + e->accept(vup); + e->accept(vdown); + e->accept(vadj); + + for (Geom::Vertex* v : vdown.getVertices()) + info._vertices.push_back(v->getName()); + for (Geom::Vertex* v : vadj.getVertices()) + info._vertices.push_back(v->getName()); + + for (Geom::Curve* c : vup.getCurves()) + info._curves.push_back(c->getName()); + for (Geom::Curve* c : vdown.getCurves()) + info._curves.push_back(c->getName()); + for (Geom::Curve* c : vadj.getCurves()) + info._curves.push_back(c->getName()); + + for (Geom::Surface* s : vup.getSurfaces()) + info._surfaces.push_back(s->getName()); + for (Geom::Surface* s : vdown.getSurfaces()) + info._surfaces.push_back(s->getName()); + for (Geom::Surface* s : vadj.getSurfaces()) + info._surfaces.push_back(s->getName()); + + for (Geom::Volume* v : vup.getVolumes()) + info._volumes.push_back(v->getName()); + for (Geom::Volume* v : vadj.getVolumes()) + info._volumes.push_back(v->getName()); + + Topo::TopoManager& tm = e->getContext().getTopoManager(); + for (Topo::TopoEntity* te : tm.getRefTopos(e)) + info._topo_entities.push_back(e->getName()); + + e->getGroupsName(info._groups); + + return info; + } +} diff --git a/src/Core/Services/MementoService.cpp b/src/Core/Services/MementoService.cpp new file mode 100644 index 00000000..ca98663d --- /dev/null +++ b/src/Core/Services/MementoService.cpp @@ -0,0 +1,145 @@ +#include "Services/MementoService.h" +#include "Geom/GeomEntity.h" +#include "Geom/GeomEntityVisitor.h" +#include "Geom/Vertex.h" +#include "Geom/Curve.h" +#include "Geom/Surface.h" +#include "Geom/Volume.h" +#include "Topo/TopoManager.h" +#include "Internal/Context.h" +#include + +namespace Mgx3D::Services +{ + + const Memento MementoService::createMemento(const Geom::GeomEntity *e) const + { + struct : Geom::ConstGeomEntityVisitor + { + void visit(const Geom::Vertex *v) override + { + fillCommonFields(v); + mem.curves = const_cast &>(v->getCurves()); + mem.groups0D = const_cast &>(v->getGroups()); + mem.occ_shapes = {v->getOCCVertex()}; + } + + void visit(const Geom::Curve *c) override + { + fillCommonFields(c); + mem.surfaces = const_cast &>(c->getSurfaces()); + mem.vertices = const_cast &>(c->getVertices()); + mem.groups1D = const_cast &>(c->getGroups()); + std::vector shapes; + for (auto e : c->getOCCEdges()) + shapes.push_back(e); + mem.occ_shapes = shapes; + } + + void visit(const Geom::Surface *s) override + { + fillCommonFields(s); + mem.curves = const_cast &>(s->getCurves()); + mem.volumes = const_cast &>(s->getVolumes()); + mem.groups2D = const_cast &>(s->getGroups()); + std::vector shapes; + for (auto f : s->getOCCFaces()) + shapes.push_back(f); + mem.occ_shapes = shapes; + } + + void visit(const Geom::Volume *v) override + { + fillCommonFields(v); + mem.surfaces = const_cast &>(v->m_surfaces); + mem.groups3D = const_cast &>(v->m_groups); + mem.occ_shapes = {v->getOCCShape()}; + } + + void fillCommonFields(const Geom::GeomEntity *e) + { + Topo::TopoManager& tm = e->getContext().getTopoManager(); + mem.topo_entities = tm.getRefTopos(e); + mem.property = e->getGeomProperty(); + } + + Memento mem; + } create_memento_visitor; + + e->accept(create_memento_visitor); + return create_memento_visitor.mem; + } + + void MementoService::saveMemento(Geom::GeomEntity *e, const Memento &mem) + { + m_mementos.insert({e, mem}); + } + + void MementoService::permMementos() + { + for (auto it = m_mementos.begin(); it != m_mementos.end(); it++) + { + Geom::GeomEntity *e = it->first; + Memento mem_saved = it->second; + it->second = createMemento(e); + setFromMemento(e, mem_saved); + } + } + + void MementoService::setFromMemento(Geom::GeomEntity *e, const Memento &mem) + { + struct : Geom::GeomEntityVisitor + { + void visit(Geom::Vertex *v) override + { + v->m_curves = m_mem.curves; + v->m_groups = m_mem.groups0D; + v->m_occ_vertex = TopoDS::Vertex(m_mem.occ_shapes[0]); + setCommonFields(v); + } + + void visit(Geom::Curve *c) override + { + c->m_surfaces = m_mem.surfaces; + c->m_vertices = m_mem.vertices; + c->m_groups = m_mem.groups1D; + c->m_occ_edges.clear(); + for (auto sh : m_mem.occ_shapes) + c->m_occ_edges.push_back(TopoDS::Edge(sh)); + setCommonFields(c); + } + + void visit(Geom::Surface *s) override + { + s->m_curves = m_mem.curves; + s->m_volumes = m_mem.volumes; + s->m_groups = m_mem.groups2D; + s->m_occ_faces.clear(); + for (auto sh : m_mem.occ_shapes) + s->m_occ_faces.push_back(TopoDS::Face(sh)); + setCommonFields(s); + } + + void visit(Geom::Volume *v) override + { + v->m_surfaces = m_mem.surfaces; + v->m_groups = m_mem.groups3D; + v->m_occ_shape = m_mem.occ_shapes[0]; + setCommonFields(v); + } + + void setCommonFields(Geom::GeomEntity *e) + { + Topo::TopoManager& tm = e->getContext().getTopoManager(); + tm.setRefTopos(e, m_mem.topo_entities); + e->setGeomProperty(m_mem.property); + e->forceComputeArea(); + } + + Memento m_mem; + } set_memento_visitor; + + set_memento_visitor.m_mem = mem; + e->accept(set_memento_visitor); + } +} diff --git a/src/Core/Topo/Block.cpp b/src/Core/Topo/Block.cpp index 638abfd1..d5572ecf 100644 --- a/src/Core/Topo/Block.cpp +++ b/src/Core/Topo/Block.cpp @@ -1502,10 +1502,24 @@ Topo::TopoInfo Block::getInfos() const Topo::TopoInfo infos; infos.name = getName(); infos.dimension = getDim(); - getVertices(infos.incident_vertices); - getCoEdges(infos.incident_coedges); - getCoFaces(infos.incident_cofaces); - infos.geom_entity = getGeomAssociation(); + if (getGeomAssociation() != 0) + infos.geom_entity = getGeomAssociation()->getName(); + + std::vector vertices; + getVertices(vertices); + for (Vertex* v : vertices) + infos._vertices.push_back(v->getName()); + + std::vector coedges; + getCoEdges(coedges); + for (CoEdge* e : coedges) + infos._coedges.push_back(e->getName()); + + std::vector cofaces; + getCoFaces(cofaces); + for (CoFace* f : cofaces) + infos._cofaces.push_back(f->getName()); + return infos; } /*----------------------------------------------------------------------------*/ diff --git a/src/Core/Topo/CoEdge.cpp b/src/Core/Topo/CoEdge.cpp index 47e8c055..58de7282 100644 --- a/src/Core/Topo/CoEdge.cpp +++ b/src/Core/Topo/CoEdge.cpp @@ -2510,12 +2510,29 @@ Topo::TopoInfo CoEdge::getInfos() const Topo::TopoInfo infos; infos.name = getName(); infos.dimension = getDim(); - getVertices(infos.incident_vertices); - //getCoEdges(infos.incident_coedges); - getEdges(infos.incident_edges); - getCoFaces(infos.incident_cofaces); - getBlocks(infos.incident_blocks); - infos.geom_entity = getGeomAssociation(); + if (getGeomAssociation() != 0) + infos.geom_entity = getGeomAssociation()->getName(); + + std::vector vertices; + getVertices(vertices); + for (Vertex* v : vertices) + infos._vertices.push_back(v->getName()); + + std::vector edges; + getEdges(edges); + for (Edge* e : edges) + infos._edges.push_back(e->getName()); + + std::vector cofaces; + getCoFaces(cofaces); + for (CoFace* f : cofaces) + infos._cofaces.push_back(f->getName()); + + std::vector blocks; + getBlocks(blocks); + for (Block* b : blocks) + infos._blocks.push_back(b->getName()); + return infos; } /*----------------------------------------------------------------------------*/ diff --git a/src/Core/Topo/CoFace.cpp b/src/Core/Topo/CoFace.cpp index 08a79ad8..f6e28109 100644 --- a/src/Core/Topo/CoFace.cpp +++ b/src/Core/Topo/CoFace.cpp @@ -1230,7 +1230,7 @@ split3(eDirOnCoFace dir, std::vector& edges1, std::vector& edges3, } /*----------------------------------------------------------------------------*/ -void CoFace:: +std::vector CoFace:: splitOgrid(eDirOnCoFace dir, std::vector& edges0, std::vector& edges1, @@ -1270,6 +1270,8 @@ splitOgrid(eDirOnCoFace dir, std::cout<<"edges1 disc en "<getNbMeshingEdges()<<" et "<getNbMeshingEdges()< splitingEdges; + if (edges1.size() == 2){ // cas de la création de 3 faces en Ogrid @@ -1472,6 +1474,9 @@ splitOgrid(eDirOnCoFace dir, coface2->add(gr); } + splitingEdges.push_back(newEdge0); + splitingEdges.push_back(newEdge1); + splitingEdges.push_back(newEdge2); } else if (edges1.size() == 3){ // cas de la création de 4 faces en Ogrid @@ -1691,10 +1696,17 @@ splitOgrid(eDirOnCoFace dir, } + splitingEdges.push_back(newEdge1); + splitingEdges.push_back(newEdge2); + splitingEdges.push_back(newEdge3); + splitingEdges.push_back(newEdge4); + splitingEdges.push_back(newEdge5); + splitingEdges.push_back(newEdge6); } // end else if (edges1.size() == 3) // destruction de la face commune actuelle free(icmd); + return splitingEdges; } /*----------------------------------------------------------------------------*/ uint CoFace::getNbVertices() const @@ -2649,12 +2661,34 @@ Topo::TopoInfo CoFace::getInfos() const Topo::TopoInfo infos; infos.name = getName(); infos.dimension = getDim(); - getVertices(infos.incident_vertices); - getCoEdges(infos.incident_coedges); - getEdges(infos.incident_edges); - getFaces(infos.incident_faces); - getBlocks(infos.incident_blocks); - infos.geom_entity = getGeomAssociation(); + if (getGeomAssociation() != 0) + infos.geom_entity = getGeomAssociation()->getName(); + + std::vector vertices; + getVertices(vertices); + for (Vertex* v : vertices) + infos._vertices.push_back(v->getName()); + + std::vector coedges; + getCoEdges(coedges); + for (CoEdge* e : coedges) + infos._coedges.push_back(e->getName()); + + std::vector edges; + getEdges(edges); + for (Edge* e : edges) + infos._edges.push_back(e->getName()); + + std::vector faces; + getFaces(faces); + for (Face* f : faces) + infos._faces.push_back(f->getName()); + + std::vector blocks; + getBlocks(blocks); + for (Block* b : blocks) + infos._blocks.push_back(b->getName()); + return infos; } /*----------------------------------------------------------------------------*/ diff --git a/src/Core/Topo/CommandDuplicateTopo.cpp b/src/Core/Topo/CommandDuplicateTopo.cpp index 420ea52e..04295895 100644 --- a/src/Core/Topo/CommandDuplicateTopo.cpp +++ b/src/Core/Topo/CommandDuplicateTopo.cpp @@ -34,15 +34,12 @@ CommandDuplicateTopo(Internal::Context& c, { // récupération des entités topologiques référencées par la géométrie concernée par la copie std::list l_te; - const std::vector& geom_entities = geom_cmd->getEntities(); - for (std::vector::const_iterator iter = geom_entities.begin(); - iter != geom_entities.end(); ++iter){ - const std::vector& refTopo = (*iter)->getRefTopo(); - - l_te.insert(l_te.end(), refTopo.begin(), refTopo.end()); + Topo::TopoManager& tm = getContext().getTopoManager(); + for (Geom::GeomEntity* ge : geom_cmd->getEntities()){ + const std::vector& topos = tm.getRefTopos(ge); + l_te.insert(l_te.end(), topos.begin(), topos.end()); } - l_te.sort(Utils::Entity::compareEntity); l_te.unique(); diff --git a/src/Core/Topo/CommandGlue2Topo.cpp b/src/Core/Topo/CommandGlue2Topo.cpp index c3e4fd1e..d2987bcc 100644 --- a/src/Core/Topo/CommandGlue2Topo.cpp +++ b/src/Core/Topo/CommandGlue2Topo.cpp @@ -1,9 +1,11 @@ /*----------------------------------------------------------------------------*/ -#include "Topo/TopoHelper.h" #include "Topo/CommandGlue2Topo.h" +#include "Topo/TopoHelper.h" +#include "Topo/TopoManager.h" #include "Topo/CoFace.h" #include "Topo/Vertex.h" #include "Geom/Volume.h" +#include "Internal/Context.h" /*----------------------------------------------------------------------------*/ #include #include @@ -46,46 +48,42 @@ internalExecute() message << "CommandGlue2Topo::execute pour la commande " << getName ( ) << " de nom unique " << getUniqueName ( ); + Topo::TopoManager& tm = getContext().getTopoManager(); // les cofaces au bord associées au premier volume - std::vector cofaces1; - std::set cofaces; - std::vector blocs; - m_vol_A->get(blocs); - Topo::TopoHelper::get(blocs, cofaces); + std::vector cofaces1; + { + std::set cofaces; + std::vector blocs = tm.getFilteredRefTopos(m_vol_A); + Topo::TopoHelper::get(blocs, cofaces); - for (std::set::iterator iter = cofaces.begin(); - iter != cofaces.end(); ++iter) - if ((*iter)->getNbBlocks() == 1) - cofaces1.push_back(*iter); + for (Topo::CoFace* coface : cofaces) + if (coface->getNbBlocks() == 1) + cofaces1.push_back(coface); #ifdef _DEBUG_GLUE - std::cout<<"cofaces1: "; - for (std::vector::iterator iter = cofaces1.begin(); - iter!=cofaces1.end(); ++iter){ - std::cout<<(*iter)->getName()<<" "; - } - std::cout<getName()<<" "; + std::cout< cofaces2; - cofaces.clear(); - blocs.clear(); - m_vol_B->get(blocs); - Topo::TopoHelper::get(blocs, cofaces); + // les cofaces au bord associées au deuxième volume + std::vector cofaces2; + { + std::set cofaces; + std::vector blocs = tm.getFilteredRefTopos(m_vol_B); + Topo::TopoHelper::get(blocs, cofaces); - for (std::set::iterator iter = cofaces.begin(); - iter != cofaces.end(); ++iter) - if ((*iter)->getNbBlocks() == 1) - cofaces2.push_back(*iter); + for (Topo::CoFace* coface : cofaces) + if (coface->getNbBlocks() == 1) + cofaces2.push_back(coface); #ifdef _DEBUG_GLUE - std::cout<<"cofaces2: "; - for (std::vector::iterator iter = cofaces2.begin(); - iter!=cofaces2.end(); ++iter){ - std::cout<<(*iter)->getName()<<" "; - } - std::cout<getName()<<" "; + std::cout<& topos = ge->getRefTopo(); + Topo::TopoManager& tm = getContext().getTopoManager(); + const std::vector& topos = tm.getRefTopos(ge); if (ge->getDim()!=0){ TkUtil::UTF8String err (TkUtil::Charset::UTF_8); @@ -998,24 +999,14 @@ getVertex(Geom::GeomEntity* ge, bool exceptionIfNotFound) std::vector CommandModificationTopo:: getVertices(Geom::GeomEntity* ge) { - const std::vector& topos = ge->getRefTopo(); - - std::vector vertices; - - for (uint i=0; igetDim()==0){ - vertices.push_back(dynamic_cast(topos[i])); - } - } - - return vertices; + Topo::TopoManager& tm = getContext().getTopoManager(); + return tm.getFilteredRefTopos(ge); } /*----------------------------------------------------------------------------*/ std::vector CommandModificationTopo:: getAllVertices(Geom::GeomEntity* ge) { - const std::vector& topos = ge->getRefTopo(); + Topo::TopoManager& tm = getContext().getTopoManager(); #ifdef _DEBUG_MAJTOPO std::cout<<"getAllVertices("<getName()<<") topos.size() = "< l_v; if (ge->getDim() == 1){ - for (uint i=0; igetDim()==1){ - Topo::CoEdge* coedge = dynamic_cast(topos[i]); - if (coedge){ - const std::vector & local_vertices = coedge->getVertices(); - l_v.insert(l_v.end(), local_vertices.begin(), local_vertices.end()); - } - } - } - // on ajoute les sommets aux extrémités + for (Topo::CoEdge* coedge : tm.getFilteredRefTopos(ge)) { + const std::vector & local_vertices = coedge->getVertices(); + l_v.insert(l_v.end(), local_vertices.begin(), local_vertices.end()); + } + + // on ajoute les sommets aux extrémités auto vertices = dynamic_cast(ge)->getVertices(); for (uint j=0; j& topos_som = vertices[j]->getRefTopo(); - for (uint i=0; igetDim()==0){ - Topo::Vertex* vtx = dynamic_cast(topos_som[i]); - if (vtx) - l_v.push_back(vtx); - } - } - } + for (Topo::Vertex* vtx : tm.getFilteredRefTopos(vertices[j])) { + l_v.push_back(vtx); + } + } } // end if (ge->getDim() == 1) else if (ge->getDim() == 2){ - for (uint i=0; igetDim()==0){ - Topo::Vertex* vertex = dynamic_cast(topos[i]); - l_v.push_back(vertex); - } - } + for (Topo::Vertex* vtx : tm.getFilteredRefTopos(ge)) { + l_v.push_back(vtx); + } } // end else if (ge->getDim() == 2) std::vector vertices; @@ -1077,29 +1053,23 @@ getAllVertices(Geom::GeomEntity* ge) std::vector CommandModificationTopo:: getCoEdges(Geom::GeomEntity* ge, Geom::GeomEntity* ge_init) { - + Topo::TopoManager& tm = getContext().getTopoManager(); std::vector coedges; if (ge->getDim() == 1){ - const std::vector& topos = ge->getRefTopo(); - for (uint i=0; igetDim()==1 && !topos[i]->isDestroyed()){ - coedges.push_back(dynamic_cast(topos[i])); - } + for (Topo::CoEdge* coedge : tm.getFilteredRefTopos(ge)) { + if (!coedge->isDestroyed()) + coedges.push_back(coedge); } } else if (ge->getDim() == 2){ bool contour_troue = false; auto curves = dynamic_cast(ge)->getCurves(); - for (std::vector::iterator iter = curves.begin(); - iter != curves.end(); ++iter){ - const std::vector& topos = (*iter)->getRefTopo(); + for (Geom::Curve* curve : curves){ uint nb_coedge = 0; - for (uint i=0; igetDim()==1 && !topos[i]->isDestroyed()){ - coedges.push_back(dynamic_cast(topos[i])); + for (Topo::CoEdge* coedge : tm.getFilteredRefTopos(curve)) { + if (!coedge->isDestroyed()){ + coedges.push_back(coedge); nb_coedge+=1; } } @@ -1144,33 +1114,26 @@ getCoEdges(Geom::GeomEntity* ge, Geom::GeomEntity* ge_init) // on recommence la recherche à partir de la surface Geom::GeomContainsImplementation gci; - for (std::vector::iterator iter = curves.begin(); - iter != curves.end(); ++iter){ - const std::vector& topos = (*iter)->getRefTopo(); - uint nb_coedge = 0; - for (uint i=0; igetDim()==1 && !topos[i]->isDestroyed()){ - nb_coedge+=1; - } - } + for (Geom::Curve* curve : curves){ + uint nb_coedge = 0; + for (Topo::CoEdge* coedge : tm.getFilteredRefTopos(curve)) { + if (!coedge->isDestroyed()){ + nb_coedge+=1; + } + } // cas où les courbes du contour n'ont aucune coedge d'associé if (nb_coedge == 0){ // on recherche si cette courbe est contenue par l'une de celles ditent intéressante - for (std::list::iterator iter2 = courbes_interessantes.begin(); - iter2 != courbes_interessantes.end(); ++iter2){ - if (gci.contains((*iter2), (*iter))){ + for (Geom::Curve* crb_int : courbes_interessantes){ + if (gci.contains(crb_int, curve)){ // on va récupérer les coedges de cette courbe - const std::vector& topos = (*iter2)->getRefTopo(); - for (std::vector::const_iterator iter3 = topos.begin(); - iter3 != topos.end(); ++iter3) - if ((*iter3)->getDim() == 1){ - Topo::CoEdge* coedge = dynamic_cast(*iter3); - if (filtre_coedge[coedge] == 1){ - filtre_coedge[coedge] = 0; // pour ne la prendre qu'une fois - coedges.push_back(coedge); - } - } + for (Topo::CoEdge* coedge : tm.getFilteredRefTopos(crb_int)) { + if (filtre_coedge[coedge] == 1){ + filtre_coedge[coedge] = 0; // pour ne la prendre qu'une fois + coedges.push_back(coedge); + } + } } } } @@ -1191,7 +1154,8 @@ getCoEdges(Geom::GeomEntity* ge, Geom::GeomEntity* ge_init) std::vector CommandModificationTopo:: getCoFaces(Geom::GeomEntity* ge, bool exceptionIfNotFound) { - const std::vector& topos = ge->getRefTopo(); + Topo::TopoManager& tm = getContext().getTopoManager(); + const std::vector& topos = tm.getRefTopos(ge); if (exceptionIfNotFound && topos.size() == 0){ TkUtil::UTF8String err (TkUtil::Charset::UTF_8); @@ -1212,12 +1176,11 @@ getCoFaces(Geom::GeomEntity* ge, bool exceptionIfNotFound) } else if (ge->getDim()==3){ auto surfaces = dynamic_cast(ge)->getSurfaces(); - for (std::vector::iterator iter = surfaces.begin(); iter != surfaces.end(); ++iter){ - const std::vector& topos = (*iter)->getRefTopo(); - for (uint i=0; igetDim()==2 && !topos[i]->isDestroyed()) - cofaces.push_back(dynamic_cast(topos[i])); + for (Geom::Surface* surface : surfaces){ + for (Topo::CoFace* coface : tm.getFilteredRefTopos(surface)) { + if (!coface->isDestroyed()) + cofaces.push_back(coface); + } } } else { @@ -1244,8 +1207,7 @@ fuseInternalCoEdgesAndVertices(Geom::GeomEntity* ge, std::vectorgetName()<& topos = ge->getRefTopo(); + Topo::TopoManager& tm = getContext().getTopoManager(); if (ge->getDim()!=2){ TkUtil::UTF8String err (TkUtil::Charset::UTF_8); @@ -1257,8 +1219,7 @@ fuseInternalCoEdgesAndVertices(Geom::GeomEntity* ge, std::vector& topos2 = newEntities[0]->getRefTopo(); - if (topos2.empty()) + if (tm.getRefTopos(newEntities[0]).empty()); return; } @@ -1267,6 +1228,7 @@ fuseInternalCoEdgesAndVertices(Geom::GeomEntity* ge, std::vector filtre_coedges; std::map filtre_vertices; + const std::vector& topos = tm.getRefTopos(ge); #ifdef _DEBUG_MAJTOPO2 std::cout<<" Relations topologiques : "< CommandModificationTopo:: getBlocks(Geom::GeomEntity* ge) { - const std::vector& topos = ge->getRefTopo(); - if (ge->getDim()!=3){ TkUtil::UTF8String err (TkUtil::Charset::UTF_8); err << "Erreur interne, ce n'est pas un volume géométrique (" @@ -1527,13 +1487,11 @@ getBlocks(Geom::GeomEntity* ge) throw TkUtil::Exception(err); } + Topo::TopoManager& tm = getContext().getTopoManager(); std::vector blocks; - - for (uint i=0; igetDim()==3 && !topos[i]->isDestroyed()){ - blocks.push_back(dynamic_cast(topos[i])); - } + for (Topo::Block* block : tm.getFilteredRefTopos(ge)) { + if (!block->isDestroyed()) + blocks.push_back(block); } return blocks; @@ -2300,9 +2258,10 @@ void CommandModificationTopo::associateInnerCoFaces(std::vector::iterator iter = filtre_surface.begin(); iter != filtre_surface.end(); ++iter) - if (iter->second >= 2 && iter->first->getRefTopo().empty()){ + if (iter->second >= 2 && tm.getRefTopos(iter->first).empty()){ Geom::Surface* surface = iter->first; std::vector coedges = getCoEdges(surface); diff --git a/src/Core/Topo/CommandNewTopoOnGeometry.cpp b/src/Core/Topo/CommandNewTopoOnGeometry.cpp index 1625e0f5..93580689 100644 --- a/src/Core/Topo/CommandNewTopoOnGeometry.cpp +++ b/src/Core/Topo/CommandNewTopoOnGeometry.cpp @@ -397,8 +397,9 @@ void CommandNewTopoOnGeometry::createCoEdge() // récupéaration des sommets auto gvertices = crv->getVertices(); std::vector tvertices; + Topo::TopoManager& tm = getContext().getTopoManager(); for (uint i=0; i ref_topo = gvertices[i]->getRefTopo(); + const std::vector ref_topo = tm.getRefTopos(gvertices[i]); if (ref_topo.size() == 1){ Topo::Vertex* vtx = dynamic_cast(ref_topo[0]); if (vtx == 0) diff --git a/src/Core/Topo/CommandSplitFaces.cpp b/src/Core/Topo/CommandSplitFaces.cpp index 171d07df..80fe9613 100644 --- a/src/Core/Topo/CommandSplitFaces.cpp +++ b/src/Core/Topo/CommandSplitFaces.cpp @@ -17,20 +17,20 @@ namespace Topo { //#define _DEBUG_SPLIT /*----------------------------------------------------------------------------*/ CommandSplitFaces:: -CommandSplitFaces(Internal::Context& c, std::vector &cofaces, CoEdge* arete, double ratio_dec, double ratio_ogrid) -:CommandEditTopo(c, "Découpage des faces 2D structurées") +CommandSplitFaces(Internal::Context& c, std::vector &cofaces, CoEdge* arete, double ratio_dec, double ratio_ogrid, bool project_on_meshing_edges) +:CommandEditTopo(c, "Découpage des faces structurées") , m_arete(arete) , m_ratio_dec(ratio_dec) , m_ratio_ogrid(ratio_ogrid) -, m_project_on_meshing_edges(true) +, m_project_on_meshing_edges(project_on_meshing_edges) { #ifdef _DEBUG_SPLIT - std::cout<<"CommandSplitFaces::CommandSplitFaces("<getName()<<", "<getName()<<", "<getName(); if (cofaces.size()>5) @@ -43,22 +43,22 @@ CommandSplitFaces(Internal::Context& c, std::vector &cofaces, Co } /*----------------------------------------------------------------------------*/ CommandSplitFaces:: -CommandSplitFaces(Internal::Context& c, std::vector &cofaces, CoEdge* arete, const Utils::Math::Point& pt, double ratio_ogrid) -:CommandEditTopo(c, "Découpage des faces 2D structurées") +CommandSplitFaces(Internal::Context& c, std::vector &cofaces, CoEdge* arete, const Utils::Math::Point& pt, double ratio_ogrid, bool project_on_meshing_edges) +:CommandEditTopo(c, "Découpage des faces structurées") , m_arete(arete) , m_ratio_dec(0) , m_ratio_ogrid(ratio_ogrid) -, m_project_on_meshing_edges(true) +, m_project_on_meshing_edges(project_on_meshing_edges) { m_ratio_dec = arete->computeRatio(pt); #ifdef _DEBUG_SPLIT - std::cout<<"CommandSplitFaces::CommandSplitFaces("<getName()<<", "<getName()<<", "<getName(); if (cofaces.size()>5) @@ -71,86 +71,50 @@ CommandSplitFaces(Internal::Context& c, std::vector &cofaces, Co } /*----------------------------------------------------------------------------*/ CommandSplitFaces:: -CommandSplitFaces(Internal::Context& c, CoEdge* arete, double ratio_dec, double ratio_ogrid) -:CommandEditTopo(c, "Découpage de toutes les faces 2D structurées") +CommandSplitFaces(Internal::Context& c, CoEdge* arete, double ratio_dec, double ratio_ogrid, bool project_on_meshing_edges) +:CommandEditTopo(c, "Découpage de toutes les faces structurées") , m_arete(arete) , m_ratio_dec(ratio_dec) , m_ratio_ogrid(ratio_ogrid) -, m_project_on_meshing_edges(true) +, m_project_on_meshing_edges(project_on_meshing_edges) { #ifdef _DEBUG_SPLIT - std::cout<<"CommandSplitFaces::CommandSplitFaces("<getName()<<", "<getName()<<", "< cofaces; getContext().getTopoManager().getCoFaces(cofaces); - init2D(cofaces); + init(cofaces); } /*----------------------------------------------------------------------------*/ CommandSplitFaces:: -CommandSplitFaces(Internal::Context& c, CoEdge* arete, const Point& pt, double ratio_ogrid) -:CommandEditTopo(c, "Découpage de toutes les faces 2D structurées") +CommandSplitFaces(Internal::Context& c, CoEdge* arete, const Point& pt, double ratio_ogrid, bool project_on_meshing_edges) +:CommandEditTopo(c, "Découpage de toutes les faces structurées") , m_arete(arete) , m_ratio_dec(0) , m_ratio_ogrid(ratio_ogrid) -, m_project_on_meshing_edges(true) +, m_project_on_meshing_edges(project_on_meshing_edges) { m_ratio_dec = arete->computeRatio(pt); #ifdef _DEBUG_SPLIT - std::cout<<"CommandSplitFaces::CommandSplitFaces("<getName()<<", "<getName()<<", "< cofaces; getContext().getTopoManager().getCoFaces(cofaces); - init2D(cofaces); + init(cofaces); } /*----------------------------------------------------------------------------*/ -CommandSplitFaces:: -CommandSplitFaces(Internal::Context& c, CoFace* coface, CoEdge* coedge, double ratio_dec, bool project_on_meshing_edges) -:CommandEditTopo(c, "Découpage de la face "+coface->getName()) -, m_arete(coedge) -, m_ratio_dec(ratio_dec) -, m_ratio_ogrid(0.0) -, m_project_on_meshing_edges(project_on_meshing_edges) +void CommandSplitFaces::init(std::vector &cofaces) { - if (!coface->isStructured()) - throw TkUtil::Exception (TkUtil::UTF8String ("Le découpage d'une face n'est possible que si elle est structurée", TkUtil::Charset::UTF_8)); - - m_cofaces.push_back(coface); #ifdef _DEBUG_SPLIT - std::cout<<"CommandSplitFaces::CommandSplitFaces("<getName()<<", "<getName()<<", "<getName()) -, m_arete(coedge) -, m_ratio_dec(0) -, m_ratio_ogrid(0.0) -, m_project_on_meshing_edges(project_on_meshing_edges) -{ - if (!coface->isStructured()) - throw TkUtil::Exception (TkUtil::UTF8String ("Le découpage d'une face n'est possible que si elle est structurée", TkUtil::Charset::UTF_8)); - - m_ratio_dec = coedge->computeRatio(pt); - - m_cofaces.push_back(coface); - -#ifdef _DEBUG_SPLIT - std::cout<<"CommandSplitFaces::CommandSplitFaces("<getName()<<", "<getName()<<", "< &cofaces) -{ -#ifdef _DEBUG_SPLIT - std::cout<<"init2D avec "<::iterator iter = cofaces.begin(); iter != cofaces.end(); ++iter){ Topo::CoFace* hcf = *iter; - if (!hcf->getNbFaces() && hcf->isStructured()){ - m_cofaces.push_back(hcf); + + if (hcf->isStructured()){ + m_cofaces.push_back(hcf); verif(hcf); #ifdef _DEBUG_SPLIT std::cout<< hcf->getName()<<" est retenue"< splitingEdges; - // découpage des faces sans chercher à boucler - TopoHelper::splitFaces(m_cofaces, m_arete, m_ratio_dec, m_ratio_ogrid, false, true, splitingEdges, &getInfoCommand()); + uint nb_faces_dep = m_cofaces.size(); + uint nb_faces_split = 0; + + std::set filtre_vertices; + std::set filtre_faces; + + std::vector splitingEdges; + + try { + do { + Vertex* sommet = 0; + CoFace* coface = 0; - // on replace les sommets en fonction de m_ratio_dec + std::vector current_splitingEdge; + std::vector coface_vec; + + if (nb_faces_split){ + + // recherche d'un bloc suivant avec une arête + if(findFaceUnmarkedWithVertexMarked(filtre_faces, filtre_vertices, coface, sommet)) { + coface_vec = {coface}; + + std::vector coedges; + coface->getCoEdges(coedges); + + CoEdge *coedge = 0; + for (std::vector::iterator iter = coedges.begin(); + iter != coedges.end(); ++iter) + if ((*iter)->find(sommet)) + coedge = *iter; + + if (coedge->getVertex(0) == sommet) + TopoHelper::splitFaces(coface_vec, coedge, 0, m_ratio_ogrid, false, false, current_splitingEdge, + &getInfoCommand()); + else if (coedge->getVertex(1) == sommet) + TopoHelper::splitFaces(coface_vec, coedge, 1, m_ratio_ogrid, false, false, current_splitingEdge, + &getInfoCommand()); + + filtre_faces.insert(coface); + } + } + else{ + std::vector arete_cofaces; + m_arete->getCoFaces(arete_cofaces); + + for (std::vector::iterator iter = arete_cofaces.begin(); + iter != arete_cofaces.end(); ++iter) + if (std::find(m_cofaces.begin(), m_cofaces.end(),*iter) != m_cofaces.end()) + coface = *iter; + + coface_vec = {coface}; + + TopoHelper::splitFaces(coface_vec, m_arete, m_ratio_dec, m_ratio_ogrid, false, true, current_splitingEdge, &getInfoCommand()); + + filtre_faces.insert(coface); + } + + nb_faces_split+=1; + + for(auto e : current_splitingEdge){ + splitingEdges.push_back(e); + filtre_vertices.insert(e->getVertex(0)); + filtre_vertices.insert(e->getVertex(1)); + } + + } while (nb_faces_dep != nb_faces_split); + } + catch (const TkUtil::Exception& exc){ + throw TkUtil::Exception(exc); + } + + // on replace les sommets en fonction de m_ratio_dec if (!m_project_on_meshing_edges) for (uint i=0; i& filtre_faces, + std::set& filtre_vertices, CoFace* &face, Vertex* &noeud) +{ + //std::cout<<"findBlockUnmarkedWithCoEdgeMarked ..."<::iterator iter1 = m_cofaces.begin(); iter1 != m_cofaces.end(); ++iter1){ + // le bloc est-il marqué ? + if (filtre_faces.find(*iter1) == filtre_faces.end()){ + CoFace* cf = *iter1; + // possède-t-il une arête marquée ? + std::vector vertices; + cf->getAllVertices(vertices); + for (std::vector::iterator iter2 = vertices.begin(); iter2 != vertices.end(); ++iter2){ + if (filtre_vertices.find(*iter2) != filtre_vertices.end()){ + noeud = *iter2; + face = cf; + return true; + } + } + } + } + return false; +} +/*----------------------------------------------------------------------------*/ void CommandSplitFaces:: countNbCoEdgesByVertices(std::map &nb_coedges_by_vertex) { diff --git a/src/Core/Topo/Edge.cpp b/src/Core/Topo/Edge.cpp index 4400587d..2e76eaf8 100644 --- a/src/Core/Topo/Edge.cpp +++ b/src/Core/Topo/Edge.cpp @@ -821,11 +821,25 @@ Topo::TopoInfo Edge::getInfos() const Topo::TopoInfo infos; infos.name = getName(); infos.dimension = getDim(); - getVertices(infos.incident_vertices); - getCoEdges(infos.incident_coedges); - getCoFaces(infos.incident_cofaces); - infos.geom_entity = getGeomAssociation(); - return infos; + if (getGeomAssociation() != 0) + infos.geom_entity = getGeomAssociation()->getName(); + + std::vector vertices; + getVertices(vertices); + for (Vertex* v : vertices) + infos._vertices.push_back(v->getName()); + + std::vector coedges; + getCoEdges(coedges); + for (CoEdge* e : coedges) + infos._coedges.push_back(e->getName()); + + std::vector cofaces; + getCoFaces(cofaces); + for (CoFace* f : cofaces) + infos._cofaces.push_back(f->getName()); + + return infos; } /*----------------------------------------------------------------------------*/ void Edge:: diff --git a/src/Core/Topo/Face.cpp b/src/Core/Topo/Face.cpp index b6ef7da8..fc870902 100644 --- a/src/Core/Topo/Face.cpp +++ b/src/Core/Topo/Face.cpp @@ -724,12 +724,30 @@ Topo::TopoInfo Face::getInfos() const Topo::TopoInfo infos; infos.name = getName(); infos.dimension = getDim(); - getVertices(infos.incident_vertices); - getCoEdges(infos.incident_coedges); - getCoFaces(infos.incident_cofaces); - getBlocks(infos.incident_blocks); - infos.geom_entity = getGeomAssociation(); - return infos; + if (getGeomAssociation() != 0) + infos.geom_entity = getGeomAssociation()->getName(); + + std::vector vertices; + getVertices(vertices); + for (Vertex* v : vertices) + infos._vertices.push_back(v->getName()); + + std::vector coedges; + getCoEdges(coedges); + for (CoEdge* e : coedges) + infos._coedges.push_back(e->getName()); + + std::vector cofaces; + getCoFaces(cofaces); + for (CoFace* f : cofaces) + infos._cofaces.push_back(f->getName()); + + std::vector blocks; + getBlocks(blocks); + for (Block* b : blocks) + infos._blocks.push_back(b->getName()); + + return infos; } /*----------------------------------------------------------------------------*/ void Face:: diff --git a/src/Core/Topo/TopoEntity.cpp b/src/Core/Topo/TopoEntity.cpp index d886381c..dcaea8f8 100644 --- a/src/Core/Topo/TopoEntity.cpp +++ b/src/Core/Topo/TopoEntity.cpp @@ -83,9 +83,9 @@ void TopoEntity::setDestroyed(bool b) std::cout<<" en relation avec "<getName()<removeRefTopo(this); + getContext().getTopoManager().removeRefTopo(ge, this); else // on remet la relation - ge->addRefTopo(this); + getContext().getTopoManager().addRefTopo(ge, this); } #ifdef _DEBUG2 else @@ -112,10 +112,11 @@ setGeomAssociation(Geom::GeomEntity* ge) #endif // on met à jour la relation réciproque (de Geom vers Topo) + Topo::TopoManager& tm = getContext().getTopoManager(); if (m_topo_property->getGeomAssociation()) - m_topo_property->getGeomAssociation()->removeRefTopo(this); + tm.removeRefTopo(m_topo_property->getGeomAssociation(), this); if (ge) - ge->addRefTopo(this); + tm.addRefTopo(ge, this); // mise à jour de la couleur si changement de dimension pour la projection Geom::GeomEntity* oldGe = m_topo_property->getGeomAssociation(); @@ -209,10 +210,11 @@ TopoProperty* TopoEntity::setProperty(TopoProperty* new_tp) // on met à jour la géométrie s'il y a une relation Geom::GeomEntity* oldge = m_topo_property->getGeomAssociation(); Geom::GeomEntity* newge = new_tp->getGeomAssociation(); + Topo::TopoManager& tm = getContext().getTopoManager(); if (oldge) - oldge->removeRefTopo(this); + tm.removeRefTopo(oldge, this); if (newge) - newge->addRefTopo(this); + tm.addRefTopo(newge, this); TopoProperty* old_tp = m_topo_property; m_topo_property = new_tp; diff --git a/src/Core/Topo/TopoHelper.cpp b/src/Core/Topo/TopoHelper.cpp index a640bdfd..1fdf6b87 100644 --- a/src/Core/Topo/TopoHelper.cpp +++ b/src/Core/Topo/TopoHelper.cpp @@ -334,24 +334,24 @@ void TopoHelper::getVertices(const std::vector & blocs, /*----------------------------------------------------------------------------*/ void TopoHelper::get(std::vector& volumes, std::set& blocks) { - for (uint j=0; j loc_blocks; - volumes[j]->get(loc_blocks); + for (Geom::Volume* vol : volumes){ + Topo::TopoManager& tm = vol->getContext().getTopoManager(); + std::vector loc_blocks = tm.getFilteredRefTopos(vol); blocks.insert(loc_blocks.begin(), loc_blocks.end()); } } /*----------------------------------------------------------------------------*/ void TopoHelper::get(std::vector& volumes, std::set& cofaces, bool propagate) { - for (uint j=0; j blocs; - volumes[j]->get(blocs); + Topo::TopoManager& tm = vol->getContext().getTopoManager(); + std::vector blocs = tm.getFilteredRefTopos(vol); Topo::TopoHelper::get(blocs, cofaces); if (propagate){ // on parcourt les surfaces pour les cas sans blocs ... - auto surfaces = volumes[j]->getSurfaces(); + auto surfaces = vol->getSurfaces(); Topo::TopoHelper::get(surfaces, cofaces); } } @@ -359,16 +359,16 @@ void TopoHelper::get(std::vector& volumes, std::set& volumes, std::set& coedges, bool propagate) { - for (uint j=0; j blocs; - volumes[j]->get(blocs); + Topo::TopoManager& tm = vol->getContext().getTopoManager(); + std::vector blocs = tm.getFilteredRefTopos(vol); Topo::TopoHelper::get(blocs, coedges); if (propagate){ Geom::GetDownIncidentGeomEntitiesVisitor v; - volumes[j]->accept(v); + vol->accept(v); std::vector surfaces (v.getSurfaces().begin(), v.getSurfaces().end()); std::vector curves (v.getCurves().begin(), v.getCurves().end()); @@ -385,8 +385,8 @@ void TopoHelper::get(std::vector& volumes, std::set blocs; - volumes[j]->get(blocs); + Topo::TopoManager& tm = volumes[j]->getContext().getTopoManager(); + std::vector blocs = tm.getFilteredRefTopos(volumes[j]); Topo::TopoHelper::get(blocs, vertices); if (propagate){ @@ -412,8 +412,8 @@ void TopoHelper::get(std::vector& volumes, std::set& surfaces, std::set& cofaces) { for (uint k=0; k loc_cofaces; - surfaces[k]->get(loc_cofaces); + Topo::TopoManager& tm = surfaces[k]->getContext().getTopoManager(); + std::vector loc_cofaces = tm.getFilteredRefTopos(surfaces[k]); cofaces.insert(loc_cofaces.begin(), loc_cofaces.end()); } } @@ -422,8 +422,8 @@ void TopoHelper::get(std::vector& surfaces, std::set cofaces; - surfaces[j]->get(cofaces); + Topo::TopoManager& tm = surfaces[j]->getContext().getTopoManager(); + std::vector cofaces = tm.getFilteredRefTopos(surfaces[j]); Topo::TopoHelper::get(cofaces, coedges); if (propagate){ @@ -437,10 +437,9 @@ void TopoHelper::get(std::vector& surfaces, std::set& surfaces, std::set& vertices, bool propagate) { for (uint j=0; j cofaces; - surfaces[j]->get(cofaces); + Topo::TopoManager& tm = surfaces[j]->getContext().getTopoManager(); + std::vector cofaces = tm.getFilteredRefTopos(surfaces[j]); Topo::TopoHelper::get(cofaces, vertices); if (propagate){ @@ -462,8 +461,8 @@ void TopoHelper::get(std::vector& surfaces, std::set& curves, std::set& coedges) { for (uint k=0; k loc_coedges; - curves[k]->get(loc_coedges); + Topo::TopoManager& tm = curves[k]->getContext().getTopoManager(); + std::vector loc_coedges = tm.getFilteredRefTopos(curves[k]); coedges.insert(loc_coedges.begin(), loc_coedges.end()); } } @@ -471,8 +470,8 @@ void TopoHelper::get(std::vector& curves, std::set& void TopoHelper::get(std::vector& curves, std::set& vertices, bool propagate) { for (uint k=0; k loc_coedges; - curves[k]->get(loc_coedges); + Topo::TopoManager& tm = curves[k]->getContext().getTopoManager(); + std::vector loc_coedges = tm.getFilteredRefTopos(curves[k]); Topo::TopoHelper::get(loc_coedges, vertices); if (propagate){ @@ -486,8 +485,8 @@ void TopoHelper::get(std::vector& curves, std::set& void TopoHelper::get(std::vector& vtx, std::set& vertices) { for (uint k=0; k loc_vertices; - vtx[k]->get(loc_vertices); + Topo::TopoManager& tm = vtx[k]->getContext().getTopoManager(); + std::vector loc_vertices = tm.getFilteredRefTopos(vtx[k]); vertices.insert(loc_vertices.begin(), loc_vertices.end()); } } @@ -805,8 +804,10 @@ void TopoHelper::splitFaces(std::vector cofaces, else { // cas 2D edge_ar = 0; - if (ind_edge_dep != 1) - reprendreCetteFace = true; + if (ind_edge_dep == 0) + edge_ar = coface->getEdge(2); + else if (ind_edge_dep == 2) + edge_ar = coface->getEdge(0); // on test pour détecter le cas d'une zone avec 1 seul sommet sur l'axe uint nb_sur_axe = 0; @@ -874,6 +875,17 @@ void TopoHelper::splitFaces(std::vector cofaces, #ifdef _DEBUG_SPLIT std::cout<<" => nbMeshingEdges_edge = "<dirCoFaceSplit = dirCoFaceSplit; + is->coedge_dep.push_back(coedge_dep); + is->edge_dep = edge_dep; + is->coedge_ar.push_back(coedge_ar); + is->edge_ar = edge_ar; + is->nbMeshingEdges_dep.push_back(nbMeshingEdges_dep); + is->nbMeshingEdges_ar.push_back(nbMeshingEdges_ar); + + cofaceInfoSplit[coface->getUniqueId()] = is; + id2coface[coface->getUniqueId()] = coface; } else { #ifdef _DEBUG_SPLIT @@ -1445,7 +1457,7 @@ void TopoHelper::splitFaces(std::vector cofaces, Edge* oldEdge0 = coface->getEdge(0); Edge* oldEdge2 = coface->getEdge(2); - coface->splitOgrid((CoFace::eDirOnCoFace)is->dirCoFaceSplit, + std::vector newEdges = coface->splitOgrid((CoFace::eDirOnCoFace)is->dirCoFaceSplit, old2newEdges[oldEdge0], newEdges_dep, old2newEdges[oldEdge2], @@ -1455,6 +1467,8 @@ void TopoHelper::splitFaces(std::vector cofaces, ratio_ogrid, icmd); + splitingEdges.insert(splitingEdges.begin(), newEdges.begin(), newEdges.end()); + // Destruction des arêtes inutiles (celles sans relation vers une CoFace) if (oldEdge0->getNbCoFaces() == 0) oldEdge0->free(icmd); @@ -1756,8 +1770,8 @@ std::vector TopoHelper::getTopoEntities(std::vector initTopoEntities; for (uint i=0; igetName()<<" ->"; - std::vector vte; - geomEntities[i]->getRefTopo(vte); + Topo::TopoManager& tm = geomEntities[i]->getContext().getTopoManager(); + std::vector vte = tm.getRefTopos(geomEntities[i]); // for (uint j=0; jgetName(); // std::cout< TopoInfo::vertices() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector TopoInfo::coedges() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector TopoInfo::edges() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector TopoInfo::cofaces() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector TopoInfo::faces() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::vector TopoInfo::blocks() const{ - std::vector v; - for(int i=0;igetName()); - return v; -} -/*----------------------------------------------------------------------------*/ -std::string TopoInfo::geomEntity() const -{ - if (geom_entity) - return geom_entity->getName(); - else - return std::string(); -} -/*----------------------------------------------------------------------------*/ -std::vector TopoInfo::groupsName() const -{ - return groups_name; -} -/*----------------------------------------------------------------------------*/ -} // end namespace Topo -/*----------------------------------------------------------------------------*/ -} // end namespace Mgx3D -/*----------------------------------------------------------------------------*/ diff --git a/src/Core/Topo/TopoManager.cpp b/src/Core/Topo/TopoManager.cpp index 3709c184..39965cfe 100644 --- a/src/Core/Topo/TopoManager.cpp +++ b/src/Core/Topo/TopoManager.cpp @@ -2576,17 +2576,17 @@ Mgx3D::Internal::M3DCommandResult* TopoManager::splitFacesWithOgrid(std::vector< return cmdResult; } /*----------------------------------------------------------------------------*/ -Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vector &cofaces_names, std::string narete, const double& ratio_dec, const double& ratio_ogrid) +Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vector &cofaces_names, std::string narete, const double& ratio_dec, const double& ratio_ogrid, bool project_on_meshing_edges) { std::vector cofaces; for (std::vector::iterator iter = cofaces_names.begin(); iter != cofaces_names.end(); ++iter){ cofaces.push_back(getCoFace(*iter)); } - return splitFaces(cofaces, getCoEdge(narete), ratio_dec, ratio_ogrid); + return splitFaces(cofaces, getCoEdge(narete), ratio_dec, ratio_ogrid, project_on_meshing_edges); } /*----------------------------------------------------------------------------*/ -Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vector &cofaces, CoEdge* arete, const double& ratio_dec, const double& ratio_ogrid) +Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vector &cofaces, CoEdge* arete, const double& ratio_dec, const double& ratio_ogrid, bool project_on_meshing_edges) { CHECK_ENTITIES_LIST(cofaces) TkUtil::UTF8String message (TkUtil::Charset::UTF_8); @@ -2599,12 +2599,16 @@ Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vectorgetName()<<","< (cofaces) << ", "; - cmd << arete->getName() <<"\", "< (cofaces) << ", \""; + cmd << arete->getName() <<"\", "<setScriptCommand(cmd); getCommandManager().addCommand(command, Utils::Command::DO); @@ -2614,17 +2618,17 @@ Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vector &cofaces_names, std::string narete, const Point& pt, const double& ratio_ogrid) +Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vector &cofaces_names, std::string narete, const Point& pt, const double& ratio_ogrid, bool project_on_meshing_edges) { std::vector cofaces; for (std::vector::iterator iter = cofaces_names.begin(); iter != cofaces_names.end(); ++iter){ cofaces.push_back(getCoFace(*iter)); } - return splitFaces(cofaces, getCoEdge(narete), pt, ratio_ogrid); + return splitFaces(cofaces, getCoEdge(narete), pt, ratio_ogrid, project_on_meshing_edges); } /*----------------------------------------------------------------------------*/ -Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vector &cofaces, CoEdge* arete, const Point& pt, const double& ratio_ogrid) +Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vector &cofaces, CoEdge* arete, const Point& pt, const double& ratio_ogrid, bool project_on_meshing_edges) { CHECK_ENTITIES_LIST(cofaces) TkUtil::UTF8String message (TkUtil::Charset::UTF_8); @@ -2637,12 +2641,16 @@ Mgx3D::Internal::M3DCommandResult* TopoManager::splitFaces(std::vectorgetName()<<","< (cofaces) << ", "; - cmd << arete->getName() <<"\", "< (cofaces) << ", \""; + cmd << arete->getName() <<"\", "<setScriptCommand(cmd); getCommandManager().addCommand(command, Utils::Command::DO); @@ -2659,12 +2667,16 @@ Mgx3D::Internal::M3DCommandResult* TopoManager::splitFace(std::string coface_nam /*----------------------------------------------------------------------------*/ Mgx3D::Internal::M3DCommandResult* TopoManager::splitFace(Topo::CoFace* coface, CoEdge* coedge, const double& ratio_dec, bool project_on_meshing_edges) { - TkUtil::UTF8String message (TkUtil::Charset::UTF_8); + TkUtil::UTF8String warning (TkUtil::Charset::UTF_8); + warning <<"La fonction splitFace est obsolete, il est préférable d'utiliser splitFaces"; + log (TkUtil::TraceLog (warning, TkUtil::Log::WARNING)); + TkUtil::UTF8String message (TkUtil::Charset::UTF_8); message <<"TopoManager::splitFace("<getName()<<", "<< coedge->getName() <<", "<< ratio_dec<<")"; log (TkUtil::TraceLog (message, TkUtil::Log::TRACE_4)); - Topo::CommandSplitFaces* command = new Topo::CommandSplitFaces(getContext(), coface, coedge, ratio_dec, project_on_meshing_edges); + std::vector cofaces = {coface}; + Topo::CommandSplitFaces* command = new Topo::CommandSplitFaces(getContext(), cofaces, coedge, ratio_dec, 0, project_on_meshing_edges); // trace dans le script TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); @@ -2695,7 +2707,8 @@ Mgx3D::Internal::M3DCommandResult* TopoManager::splitFace(Topo::CoFace* coface, message <<"TopoManager::splitFace("<getName()<<", "<< coedge->getName() <<", "<< pt<<")"; log (TkUtil::TraceLog (message, TkUtil::Log::TRACE_4)); - Topo::CommandSplitFaces* command = new Topo::CommandSplitFaces(getContext(), coface, coedge, pt, project_on_meshing_edges); + std::vector cofaces = {coface}; + Topo::CommandSplitFaces* command = new Topo::CommandSplitFaces(getContext(), cofaces, coedge, pt, 0, project_on_meshing_edges); // trace dans le script TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); @@ -2744,24 +2757,29 @@ TopoManager::extendSplitFace(Topo::CoFace* coface, Vertex* vertex) return cmdResult; } /*----------------------------------------------------------------------------*/ -Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(std::string narete, const double& ratio_dec, const double& ratio_ogrid) +Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(std::string narete, const double& ratio_dec, const double& ratio_ogrid, bool project_on_meshing_edges) { - return splitAllFaces(getCoEdge(narete), ratio_dec, ratio_ogrid); + return splitAllFaces(getCoEdge(narete), ratio_dec, ratio_ogrid, project_on_meshing_edges); } /*----------------------------------------------------------------------------*/ -Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(CoEdge* coedge, const double& ratio_dec, const double& ratio_ogrid) +Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(CoEdge* coedge, const double& ratio_dec, const double& ratio_ogrid, bool project_on_meshing_edges) { TkUtil::UTF8String message (TkUtil::Charset::UTF_8); message <<"TopoManager::splitAllFaces("; message <getName()<<","<getName() <<"\", "<getName() <<"\", "<setScriptCommand(cmd); getCommandManager().addCommand(command, Utils::Command::DO); @@ -2771,12 +2789,12 @@ Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(CoEdge* coedge, co return cmdResult; } /*----------------------------------------------------------------------------*/ -Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(std::string narete, const Point& pt, const double& ratio_ogrid) +Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(std::string narete, const Point& pt, const double& ratio_ogrid, bool project_on_meshing_edges) { - return splitAllFaces(getCoEdge(narete), pt, ratio_ogrid); + return splitAllFaces(getCoEdge(narete), pt, ratio_ogrid, project_on_meshing_edges); } /*----------------------------------------------------------------------------*/ -Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(CoEdge* coedge, const Point& pt, const double& ratio_ogrid) +Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(CoEdge* coedge, const Point& pt, const double& ratio_ogrid, bool project_on_meshing_edges) { TkUtil::UTF8String message (TkUtil::Charset::UTF_8); message <<"TopoManager::splitAllFaces("; @@ -2788,7 +2806,11 @@ Mgx3D::Internal::M3DCommandResult* TopoManager::splitAllFaces(CoEdge* coedge, co // trace dans le script TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); cmd << getContextAlias() << "." << "getTopoManager().splitAllFaces (\""; - cmd << coedge->getName() <<"\", "<getName() <<"\", "<setScriptCommand(cmd); getCommandManager().addCommand(command, Utils::Command::DO); @@ -5552,25 +5574,48 @@ Internal::M3DCommandResult* TopoManager::exportBlocks(const std::string& n) return cmdResult; } /*----------------------------------------------------------------------------*/ - Internal::M3DCommandResult* TopoManager::importBlocks(const std::string& n) - { - //creation de la commande d'exportation - CommandImportBlocks *command = new CommandImportBlocks(getContext(), n); +Internal::M3DCommandResult* TopoManager::importBlocks(const std::string& n) +{ + //creation de la commande d'exportation + CommandImportBlocks *command = new CommandImportBlocks(getContext(), n); - // trace dans le script - TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); - cmd << getContextAlias() << "." << "getTopoManager().importBlocks("; - cmd <<"\""<setScriptCommand(cmd); + // trace dans le script + TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); + cmd << getContextAlias() << "." << "getTopoManager().importBlocks("; + cmd <<"\""<setScriptCommand(cmd); - // on passe au gestionnaire de commandes qui exécute la commande en // ou non - // et la stocke dans le gestionnaire de undo-redo si c'est une réussite - getCommandManager().addCommand(command, Utils::Command::DO); + // on passe au gestionnaire de commandes qui exécute la commande en // ou non + // et la stocke dans le gestionnaire de undo-redo si c'est une réussite + getCommandManager().addCommand(command, Utils::Command::DO); - Internal::M3DCommandResult* cmdResult = - new Internal::M3DCommandResult (*command); - return cmdResult; - } + Internal::M3DCommandResult* cmdResult = + new Internal::M3DCommandResult (*command); + return cmdResult; +} +/*----------------------------------------------------------------------------*/ +const std::vector& TopoManager::getRefTopos(const Geom::GeomEntity* ge) +{ + return m_geom_associations[ge]; +} +/*----------------------------------------------------------------------------*/ +void TopoManager::addRefTopo(const Geom::GeomEntity* ge, TopoEntity* te) +{ + m_geom_associations[ge].push_back(te); +} +/*----------------------------------------------------------------------------*/ +void TopoManager::removeRefTopo(const Geom::GeomEntity* ge, TopoEntity* te) +{ + std::vector& v = m_geom_associations[ge]; + // on supprime toutes les occurrences de te dans le vecteur + // (même si en principe il ne devrait y en avoir qu'une seule) + v.erase(std::remove(v.begin(), v.end(), te), v.end()); +} +/*----------------------------------------------------------------------------*/ +void TopoManager::setRefTopos(const Geom::GeomEntity* ge, const std::vector& tes) +{ + m_geom_associations[ge] = tes; +} /*----------------------------------------------------------------------------*/ } // end namespace Topo /*----------------------------------------------------------------------------*/ diff --git a/src/Core/Topo/Vertex.cpp b/src/Core/Topo/Vertex.cpp index 81f511f9..41407b9d 100644 --- a/src/Core/Topo/Vertex.cpp +++ b/src/Core/Topo/Vertex.cpp @@ -603,11 +603,29 @@ Topo::TopoInfo Vertex::getInfos() const Topo::TopoInfo infos; infos.name = getName(); infos.dimension = getDim(); - getCoEdges(infos.incident_coedges); - getEdges(infos.incident_edges); - getCoFaces(infos.incident_cofaces); - getBlocks(infos.incident_blocks); - infos.geom_entity = getGeomAssociation(); + if (getGeomAssociation() != 0) + infos.geom_entity = getGeomAssociation()->getName(); + + std::vector coedges; + getCoEdges(coedges); + for (CoEdge* e : coedges) + infos._coedges.push_back(e->getName()); + + std::vector edges; + getEdges(edges); + for (Edge* e : edges) + infos._edges.push_back(e->getName()); + + std::vector cofaces; + getCoFaces(cofaces); + for (CoFace* f : cofaces) + infos._cofaces.push_back(f->getName()); + + std::vector blocks; + getBlocks(blocks); + for (Block* b : blocks) + infos._blocks.push_back(b->getName()); + return infos; } /*----------------------------------------------------------------------------*/ diff --git a/src/Core/protected/Geom/CommandCreateWithOtherGeomEntities.h b/src/Core/protected/Geom/CommandCreateWithOtherGeomEntities.h index 100c5f92..bd877113 100644 --- a/src/Core/protected/Geom/CommandCreateWithOtherGeomEntities.h +++ b/src/Core/protected/Geom/CommandCreateWithOtherGeomEntities.h @@ -2,7 +2,7 @@ #define COMMANDCREATEWITHOTHERGEOMENTITIES_H_ /*----------------------------------------------------------------------------*/ #include "Geom/CommandCreateGeom.h" -#include "Geom/MementoManager.h" +#include "Services/MementoService.h" /*----------------------------------------------------------------------------*/ namespace Mgx3D { /*----------------------------------------------------------------------------*/ @@ -44,7 +44,7 @@ class CommandCreateWithOtherGeomEntities: public Geom::CommandCreateGeom { void internalRedo(); protected: - MementoManager m_memento_manager; + Services::MementoService m_memento_service; }; /*----------------------------------------------------------------------------*/ } // end namespace Geom diff --git a/src/Core/protected/Geom/CommandEditGeom.h b/src/Core/protected/Geom/CommandEditGeom.h index 2672baaf..f9237f85 100644 --- a/src/Core/protected/Geom/CommandEditGeom.h +++ b/src/Core/protected/Geom/CommandEditGeom.h @@ -3,7 +3,7 @@ /*----------------------------------------------------------------------------*/ #include "Geom/CommandCreateGeom.h" #include "Geom/GeomModificationBaseClass.h" -#include "Geom/MementoManager.h" +#include "Services/MementoService.h" /*----------------------------------------------------------------------------*/ #include /*----------------------------------------------------------------------------*/ @@ -126,7 +126,7 @@ class CommandEditGeom: public Geom::CommandCreateGeom { /** parcours les entités modifiées par l'opération géométrique et pour * celles modifiées dans entities, conserve le memento associé */ - void saveMementos(std::map & entities); + void saveMementos(std::map & entities); /*------------------------------------------------------------------------*/ /** Copie les groupes d'une entité vers une autre (de même dimension) */ @@ -137,8 +137,7 @@ class CommandEditGeom: public Geom::CommandCreateGeom { protected: - - MementoManager m_memento_manager; + Services::MementoService m_memento_service; /* objet gérant l'opération OCC*/ GeomModificationBaseClass* m_impl; diff --git a/src/Core/protected/Geom/Curve.h b/src/Core/protected/Geom/Curve.h index 5deabd22..2ba26388 100644 --- a/src/Core/protected/Geom/Curve.h +++ b/src/Core/protected/Geom/Curve.h @@ -7,6 +7,7 @@ /*----------------------------------------------------------------------------*/ #include "Geom/GeomEntity.h" #include "Geom/GeomProperty.h" +#include "Services/MementoService.h" #include "Utils/Point.h" #include "Utils/Vector.h" /*----------------------------------------------------------------------------*/ @@ -17,10 +18,6 @@ namespace Mgx3D { namespace Group { class Group1D; } -namespace Topo { -class CoEdge; -class Vertex; -} /*----------------------------------------------------------------------------*/ namespace Geom { @@ -33,7 +30,7 @@ class GeomProperty; */ class Curve: public GeomEntity { - friend class MementoManager; + friend class Services::MementoService; static const char* typeNameGeomCurve; public: @@ -47,10 +44,8 @@ class Curve: public GeomEntity { * \param gprop les propriétés associées à la courbe * \param shape la shape OCC */ -#ifndef SWIG Curve(Internal::Context& ctx, Utils::Property* prop, Utils::DisplayProperties* disp, GeomProperty* gprop, TopoDS_Edge& shape); -#endif /*------------------------------------------------------------------------*/ /** \brief Constructeur @@ -61,10 +56,9 @@ class Curve: public GeomEntity { * \param gprop les propriétés associées à la courbe * \param shapes les shapes OCC */ -#ifndef SWIG Curve(Internal::Context& ctx, Utils::Property* prop, Utils::DisplayProperties* disp, GeomProperty* gprop, std::vector& shapes); -#endif + const std::vector& getOCCEdges() const { return m_occ_edges; } virtual void apply(std::function const& lambda) const; @@ -104,14 +98,6 @@ class Curve: public GeomEntity { */ virtual void computeBoundingBox(Utils::Math::Point& pmin, Utils::Math::Point& pmax) const; - /*------------------------------------------------------------------------*/ - /// retourne la liste des arêtes topologiques communes qui pointent sur cette courbe - virtual void get(std::vector& coedges); - - /*------------------------------------------------------------------------*/ - /// retourne la liste des sommets topologiques qui pointent sur cette courbe - virtual void get(std::vector& vertices); - /*------------------------------------------------------------------------*/ /** \brief Donne le point en fonction du paramètre sur la courbe * \param p le paramètre curviligne @@ -152,7 +138,6 @@ class Curve: public GeomEntity { * \param l_ratios les ratios pour les paramètres entre Pt0 et Pt1 * \param l_points les points calculés, en retour */ -#ifndef SWIG void getParametricsPoints(const Utils::Math::Point& Pt0, const Utils::Math::Point& Pt1, const uint nbPt, @@ -170,7 +155,7 @@ class Curve: public GeomEntity { double* l_ratios, std::vector &points, const Utils::Math::Point& polar_center); -#endif + /*------------------------------------------------------------------------*/ /** \brief Access to the first end point * @@ -188,19 +173,14 @@ class Curve: public GeomEntity { * * \param s un pointeur sur une surface */ - -#ifndef SWIG void add(Surface* s); -#endif /*------------------------------------------------------------------------*/ /** \brief Ajoute v comme sommet incident * * \param v un pointeur sur un sommet */ -#ifndef SWIG void add (Vertex* v); -#endif /*------------------------------------------------------------------------*/ /** \brief Supprime s de la liste des surfaces incidentes. Si s n'apparait @@ -208,9 +188,7 @@ class Curve: public GeomEntity { * * \param s un pointeur sur une surface */ -#ifndef SWIG void remove(Surface* s); -#endif /*------------------------------------------------------------------------*/ /** \brief Supprime v de la liste des sommets incidents. Si v n'apparait @@ -218,9 +196,7 @@ class Curve: public GeomEntity { * * \param v un pointeur sur un sommet */ -#ifndef SWIG void remove(Vertex* v); -#endif /*------------------------------------------------------------------------*/ /** \brief Ajoute à la liste les entités de niveaux inférieurs @@ -228,9 +204,7 @@ class Curve: public GeomEntity { * * \param liste d'entity */ -#ifndef SWIG virtual void addAllDownLevelEntity(std::list& l_entity) const; -#endif /*------------------------------------------------------------------------*/ /** \brief retourne un point sur l'objet au centre si possible @@ -260,20 +234,14 @@ class Curve: public GeomEntity { /*------------------------------------------------------------------------*/ /** Ajoute le groupe parmis ceux auxquels appartient la courbe */ -#ifndef SWIG void add(Group::Group1D* grp); -#endif /** Retire le groupe parmis ceux auxquels appartient la courbe */ -#ifndef SWIG void remove(Group::Group1D* grp); -#endif /** Recherche le groupe parmis ceux auxquels appartient la courbe * return vrai si trouvé */ -#ifndef SWIG bool find(Group::Group1D* grp); -#endif /// Retourne les noms des groupes auxquels appartient cette entité virtual void getGroupsName (std::vector& gn) const; @@ -284,9 +252,6 @@ class Curve: public GeomEntity { /// Retourne la liste des groupes auxquels appartient cette entité virtual const std::vector& getGroups() const {return m_groups;} - /// Affecte une nouvelle liste des groupes auxquels appartient cette entité - virtual void setGroups(std::vector& grp); - /// Retourne le nombre de groupes virtual int getNbGroups() const; @@ -303,9 +268,7 @@ class Curve: public GeomEntity { /*------------------------------------------------------------------------*/ /** \brief détruit l'objet */ -#ifndef SWIG virtual void setDestroyed(bool b); -#endif /*------------------------------------------------------------------------*/ /** \brief indique si la courbe est un segment ou pas @@ -327,18 +290,6 @@ class Curve: public GeomEntity { */ bool isBSpline() const; - /*------------------------------------------------------------------------*/ - /** \brief Fournit une représentation textuelle de l'entité. - * \param true si l'entité fourni la totalité de sa description, false si - * elle ne fournit que les informations non calculées (objectif : - * optimisation) - * \return Description, à détruire par l'appelant. - */ -#ifndef SWIG - virtual Mgx3D::Utils::SerializedRepresentation* getDescription ( - bool alsoComputed) const; -#endif - private: std::vector m_surfaces; std::vector m_vertices; diff --git a/src/Core/protected/Geom/GeomEntity.h b/src/Core/protected/Geom/GeomEntity.h index 4469275b..fea60fa0 100644 --- a/src/Core/protected/Geom/GeomEntity.h +++ b/src/Core/protected/Geom/GeomEntity.h @@ -13,7 +13,7 @@ #include "Utils/Point.h" #include "Geom/GeomProperty.h" #include "Geom/GeomEntityVisitor.h" -#include "Topo/TopoEntity.h" +#include "Services/DescriptionService.h" /*----------------------------------------------------------------------------*/ #include /*----------------------------------------------------------------------------*/ @@ -57,9 +57,6 @@ class MementoEntity; * */ class GeomEntity : public Internal::InternalEntity{ - - friend class MementoManager; - protected: /*------------------------------------------------------------------------*/ /** \brief Constructeur. Une entité délègue un certain nombre de calculs @@ -95,19 +92,14 @@ class GeomEntity : public Internal::InternalEntity{ * \param En retour, la boite englobante définit comme suit * (xmin, xmax, ymin, ymax, zmin, zmax). */ -#ifndef SWIG virtual void getBounds (double bounds[6]) const; -#endif // SWIG /*------------------------------------------------------------------------*/ /** \brief MAJ de la propriété. Par défaut, la propriété précédente est * retournée */ -#ifndef SWIG GeomProperty* setGeomProperty(GeomProperty* prop); -#endif -public: /*------------------------------------------------------------------------*/ /** \brief Calcule l'aire d'une entité: Pour une courbe, c'est la * longueur, pour une surface, l'aire, pour un volume le volume. @@ -126,6 +118,8 @@ class GeomEntity : public Internal::InternalEntity{ virtual void setArea(double area) {m_computedArea = area;} + void forceComputeArea() { m_computedAreaIsUpToDate = false; } + /*------------------------------------------------------------------------*/ /** \brief Calcul de la boite englobante orientée selon les axes Ox,Oy,Oz * @@ -143,9 +137,7 @@ class GeomEntity : public Internal::InternalEntity{ /*------------------------------------------------------------------------*/ /** \brief Fournit l'accès à la propriété de l'entité géométrique */ -#ifndef SWIG virtual GeomProperty* getGeomProperty() const { return m_geomProp; } -#endif /*------------------------------------------------------------------------*/ /** \return Le type d'entité géométrique. Raccourci sur @@ -160,60 +152,17 @@ class GeomEntity : public Internal::InternalEntity{ * \param dr la représentation que l'on demande à afficher * \param Lève une exception si checkDestroyed vaut true */ -#ifndef SWIG virtual void getRepresentation( Mgx3D::Utils::DisplayRepresentation& dr, bool checkDestroyed) const; -#endif -private: -#ifndef SWIG - template - void buildSerializedRepresentation(Utils::SerializedRepresentation& description, const std::string& title, - const Utils::EntitySet elements) const; -#endif - -private: -#ifndef SWIG - template - void buildSerializedRepresentation(Utils::SerializedRepresentation& description, const std::string& title, - const std::vector elements) const; -#endif -public: - /*------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------*/ /** \brief Fournit une représentation textuelle de l'entité. * \param true si l'entité fourni la totalité de sa description, false si * elle ne fournit que les informations non calculées (objectif : * optimisation) * \return Description, à détruire par l'appelant. */ -#ifndef SWIG - virtual Mgx3D::Utils::SerializedRepresentation* getDescription ( - bool alsoComputed) const; -#endif - - /*------------------------------------------------------------------------*/ - /** Ajoute une relation vers la topologie - * Il est vérifié que la relation n'y ait pas déjà - * */ -#ifndef SWIG - virtual void addRefTopo(Topo::TopoEntity* te); -#endif - - /** Enlève une relation vers la topologie - * Il est vérifié que la relation y ait déjà - * */ -#ifndef SWIG - virtual void removeRefTopo(Topo::TopoEntity* te); -#endif - - /** Retourne la liste des entités topologiques référencées */ -#ifndef SWIG - virtual void getRefTopo(std::vector& vte) const; - virtual const std::vector& getRefTopo() const - { return m_topo_entities; } - virtual void setRefTopo(const std::vector& vte) - { m_topo_entities = vte; } -#endif + virtual Mgx3D::Utils::SerializedRepresentation* getDescription (bool alsoComputed) const; /*------------------------------------------------------------------------*/ /// Retourne les noms des groupes auxquels appartient cette entité @@ -222,9 +171,6 @@ class GeomEntity : public Internal::InternalEntity{ /// Retourne la liste des groupes auxquels appartient cette entité virtual void getGroups(std::vector& grp) const; - /// Affecte une nouvelle liste des groupes auxquels appartient cette entité - virtual void setGroups(std::vector& grp); - /// Retourne le nombre de groupes virtual int getNbGroups() const; @@ -232,9 +178,6 @@ class GeomEntity : public Internal::InternalEntity{ /// Propriétés géométriques (qui peut être spécifique, PropertyBox par exemple) GeomProperty* m_geomProp; - /// liens vers la topologie - std::vector m_topo_entities; - /// pour savoir si computeArea doit être appelé mutable bool m_computedAreaIsUpToDate; diff --git a/src/Core/protected/Geom/GeomInfo.h b/src/Core/protected/Geom/GeomInfo.h index bd7d0939..36baf353 100644 --- a/src/Core/protected/Geom/GeomInfo.h +++ b/src/Core/protected/Geom/GeomInfo.h @@ -1,51 +1,33 @@ #ifndef GEOMINFO_H_ #define GEOMINFO_H_ -/*----------------------------------------------------------------------------*/ + #include #include -/*----------------------------------------------------------------------------*/ -namespace Mgx3D { -/*----------------------------------------------------------------------------*/ -namespace Topo { -class TopoEntity; -} -/*----------------------------------------------------------------------------*/ -namespace Geom { -/*----------------------------------------------------------------------------*/ -class Vertex; -class Curve; -class Surface; -class Volume; -/*----------------------------------------------------------------------------*/ -class GeomInfo{ -public: - std::string name; - int dimension; - /// longueur d'une courbe, aire d'une surface, volume d'un volume - double area; +namespace Mgx3D::Geom +{ + struct GeomInfo + { + std::string name; + int dimension; + /// longueur d'une courbe, aire d'une surface, volume d'un volume + double area; + + std::vector vertices() const { return _vertices; } + std::vector curves() const { return _curves; } + std::vector surfaces() const { return _surfaces; } + std::vector volumes() const { return _volumes; } + std::vector topo_entities() const { return _topo_entities; } + std::vector groups() const { return _groups; } + #ifndef SWIG - std::vector incident_vertices; - std::vector incident_curves; - std::vector incident_surfaces; - std::vector incident_volumes; - std::vector topo_entities; - std::vector groups_name; + std::vector _vertices; + std::vector _curves; + std::vector _surfaces; + std::vector _volumes; + std::vector _topo_entities; + std::vector _groups; #endif - - std::vector vertices() const; - std::vector curves() const; - std::vector surfaces() const; - std::vector volumes() const; - std::vector topoEntities() const; - std::vector groupsName() const; -}; -/*----------------------------------------------------------------------------*/ -} // end namespace Geom -/*----------------------------------------------------------------------------*/ -} // end namespace Mgx3D -/*----------------------------------------------------------------------------*/ + }; +} #endif /* GEOMINFO_H_ */ - -/*----------------------------------------------------------------------------*/ - diff --git a/src/Core/protected/Geom/GeomManager.h b/src/Core/protected/Geom/GeomManager.h index 9ca26e79..2ebbd917 100644 --- a/src/Core/protected/Geom/GeomManager.h +++ b/src/Core/protected/Geom/GeomManager.h @@ -87,9 +87,12 @@ class GeomManager final : public Internal::CommandCreator { */ GeomInfo getInfos(std::string e, int dim); SET_SWIG_COMPLETABLE_METHOD(getInfos) + std::string getTextualDescription(std::string e, int dim); + SET_SWIG_COMPLETABLE_METHOD(getTextualDescription) #ifndef SWIG GeomInfo getInfos(const GeomEntity* e); + std::string getTextualDescription(const GeomEntity* e); #endif /** retourne les coordonnés d'un sommet */ @@ -1463,6 +1466,9 @@ class GeomManager final : public Internal::CommandCreator { #endif private: + /// Retourne vrai si l'une des entités géométriques a un lien sur une entité topologique + bool hasRefTopo(std::vector& entities); + /** volumes gérés par le manager */ std::vector m_volumes; /** surfaces gérées par le manager */ diff --git a/src/Core/protected/Geom/MementoEntity.h b/src/Core/protected/Geom/MementoEntity.h deleted file mode 100644 index eeef101c..00000000 --- a/src/Core/protected/Geom/MementoEntity.h +++ /dev/null @@ -1,176 +0,0 @@ -#ifndef MGX3D_MEMENTOENTITY_H_ -#define MGX3D_MEMENTOENTITY_H_ -/*----------------------------------------------------------------------------*/ -#include -/*----------------------------------------------------------------------------*/ -#include -/*----------------------------------------------------------------------------*/ -namespace Mgx3D { -/*----------------------------------------------------------------------------*/ -namespace Topo -{ - class TopoEntity; -} - -namespace Group -{ - class Group0D; - class Group1D; - class Group2D; - class Group3D; -} -/*----------------------------------------------------------------------------*/ -namespace Geom { -/*----------------------------------------------------------------------------*/ -class GeomProperty; -class Volume; -class Surface; -class Curve; -class Vertex; -/*----------------------------------------------------------------------------*/ -/** - * \class MementoEntity - * \brief Classe permettant le stockage des informations caractérisant une - * entité géométrique dans le cadre du undo/redo. - * - * Par défaut, le système de commandes de Mgx3D permet de stocker les - * entités de Magix3D qui ont été supprimées, modifiées et/ou ajoutées. - * Dans le cas d'entités que l'on modifie, c'est de leur responsabilité - * de stocker leurs "modifications". La classe MementoEntity joue - * ce rôle pour les entités géométriques. - * - * Dans le cadre du pattern Mémento, la classe MementoEntity joue - * le rôle de Mémento, les classes filles de GeomEntity jouent le rôle - * de créateurs et les classes de Commandes géométriques ayant besoin - * de ce type d'informations de sauvegarde jouent le rôle de Demandeur - * et de Gardien des mémentos. - * - * Pour le moment, une seule classe de Mémento géométrique est mise en - * place (celle-ci). Il est possible qu'il soit nécessaire de - * spécialiser le mémento pour chaque type d'entités géométriques - * (sommets, courbes, surfaces, volumes) - * - */ -class MementoEntity -{ -public: - - /*------------------------------------------------------------------------*/ - /** \brief Constructeur. - */ - MementoEntity() -: m_property(0) -{;} - - /*------------------------------------------------------------------------*/ - /** \brief Destructeur - */ - virtual ~MementoEntity(){;} - - inline std::vector& - getTopoEntities() { - return m_topo_entities; - } - inline void setTopoEntities(std::vector& topoEntities){ - m_topo_entities = topoEntities; - } - - inline std::vector& getVolumes() { - return m_volumes; - } - inline void setVolumes(std::vector& entities) { - m_volumes = entities; - } - - inline std::vector& getSurfaces() { - return m_surfaces; - } - inline void setSurfaces(std::vector& entities) { - m_surfaces = entities; - } - - inline std::vector& getCurves() { - return m_curves; - } - inline void setCurves(std::vector& entities) { - m_curves = entities; - } - - inline std::vector& getVertices() { - return m_vertices; - } - inline void setVertices(std::vector& entities) { - m_vertices = entities; - } - - inline std::vector& getGroups0D() { - return m_groups0D; - } - inline void setGroups0D(std::vector& grps) { - m_groups0D = grps; - } - - inline std::vector& getGroups1D() { - return m_groups1D; - } - inline void setGroups1D(std::vector& grps) { - m_groups1D = grps; - } - - inline std::vector& getGroups2D() { - return m_groups2D; - } - inline void setGroups2D(std::vector& grps) { - m_groups2D = grps; - } - - inline std::vector& getGroups3D() { - return m_groups3D; - } - inline void setGroups3D(std::vector& grps) { - m_groups3D = grps; - } - - inline std::vector& getOCCShapes() { - return m_shapes; - } - inline void setOCCShapes(const std::vector& g) { - m_shapes = g; - } - - inline GeomProperty* getProperty() { - return m_property; - } - inline void setProperty(GeomProperty* g) { - m_property = g; - } -private : - - /// liens vers la topologie - std::vector m_topo_entities; - - std::vector m_volumes; - std::vector m_surfaces; - std::vector m_curves; - std::vector m_vertices; - - /// Listes des groupes 1D auxquels appartient cette courbe - std::vector m_groups0D; - std::vector m_groups1D; - std::vector m_groups2D; - std::vector m_groups3D; - - /* ancienne représentation géométrique des entités que l'on a modifiées */ - std::vector m_shapes; - - /* ancienne propriétés des entités que l'on a modifiées. Il - * est de la responsabilité de l'objet de les détruire */ - GeomProperty* m_property; -}; -/*----------------------------------------------------------------------------*/ -} // end namespace Geom -/*----------------------------------------------------------------------------*/ -} // end namespace Mgx3D -/*----------------------------------------------------------------------------*/ -#endif /* MGX3D_MEMENTOENTITY_H_ */ -/*----------------------------------------------------------------------------*/ diff --git a/src/Core/protected/Geom/MementoManager.h b/src/Core/protected/Geom/MementoManager.h deleted file mode 100644 index a82ab959..00000000 --- a/src/Core/protected/Geom/MementoManager.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef MEMENTO_MANAGER_H_ -#define MEMENTO_MANAGER_H_ -/*----------------------------------------------------------------------------*/ -#include "Geom/MementoEntity.h" -/*----------------------------------------------------------------------------*/ -#include -/*----------------------------------------------------------------------------*/ -namespace Mgx3D { -/*----------------------------------------------------------------------------*/ -namespace Geom { -/*----------------------------------------------------------------------------*/ -class GeomEntity; -/*----------------------------------------------------------------------------*/ -class MementoManager -{ -public: - MementoManager() = default; - ~MementoManager() = default; - - const MementoEntity createMemento(const GeomEntity* e) const; - void saveMemento(GeomEntity* e, const MementoEntity& mem); - void saveMemento(GeomEntity* e) { saveMemento(e, createMemento(e)); } - void permMementos(); - -private : - void setFromMemento(GeomEntity* e, const MementoEntity& mem); - - /** pour les entitiés géométriques modifiées lors de l'opération, on - * stocke leur "état interne" sous forme de mémento. Ce stockage est de la - * responsabilité de chaque entité */ - std::map m_mementos; -}; -/*----------------------------------------------------------------------------*/ -} // end namespace Geom -/*----------------------------------------------------------------------------*/ -} // end namespace Mgx3D -/*----------------------------------------------------------------------------*/ -#endif /* MEMENTO_MANAGER_H_ */ -/*----------------------------------------------------------------------------*/ diff --git a/src/Core/protected/Geom/Surface.h b/src/Core/protected/Geom/Surface.h index f0b04588..8e1ae5e5 100644 --- a/src/Core/protected/Geom/Surface.h +++ b/src/Core/protected/Geom/Surface.h @@ -2,6 +2,7 @@ #define MGX3D_GEOM_SURFACE_H_ /*----------------------------------------------------------------------------*/ #include "Geom/GeomEntity.h" +#include "Services/MementoService.h" #include "Utils/Vector.h" #include "Utils/Point.h" /*----------------------------------------------------------------------------*/ @@ -15,11 +16,6 @@ namespace Group { class Group2D; } -namespace Topo { -class CoFace; -class CoEdge; -class Vertex; -} /*----------------------------------------------------------------------------*/ namespace Geom { /*----------------------------------------------------------------------------*/ @@ -36,7 +32,7 @@ class GeomProperty; */ class Surface: public GeomEntity { - friend class MementoManager; + friend class Services::MementoService; static const char* typeNameGeomSurface; public: @@ -50,10 +46,8 @@ class Surface: public GeomEntity { * \param gprop les propriétés associées à la surface * \param shape la shape OCC */ -#ifndef SWIG Surface(Internal::Context& ctx, Utils::Property* prop, Utils::DisplayProperties* disp, GeomProperty* gprop, TopoDS_Face& shape); -#endif /** \brief Constructeur * @@ -63,10 +57,9 @@ class Surface: public GeomEntity { * \param gprop les propriétés associées à la surface composite * \param shapes les shapes OCC */ -#ifndef SWIG Surface(Internal::Context& ctx, Utils::Property* prop, Utils::DisplayProperties* disp, GeomProperty* gprop, std::vector& shapes); -#endif + const std::vector& getOCCFaces() const { return m_occ_faces; } virtual void apply(std::function const& lambda) const; @@ -125,15 +118,14 @@ class Surface: public GeomEntity { * * \param v un pointeur sur un volume */ -#ifndef SWIG - virtual void add(Volume* v); - -#endif + virtual void add(Volume* v); - -#ifndef SWIG + /*------------------------------------------------------------------------*/ + /** \brief Ajoute c comme courbe incidente + * + * \param c un pointeur sur une courbe + */ virtual void add(Curve* c); -#endif /*------------------------------------------------------------------------*/ /** \brief Supprime v de la liste des volumes incidents. Si v n'apparait @@ -141,9 +133,7 @@ class Surface: public GeomEntity { * * \param v un pointeur sur un volume */ -#ifndef SWIG virtual void remove(Volume* v); -#endif /*------------------------------------------------------------------------*/ /** \brief Supprime c de la liste des courbes incidentes. Si c n'apparait @@ -151,9 +141,7 @@ class Surface: public GeomEntity { * * \param v un pointeur sur un volume */ -#ifndef SWIG virtual void remove(Curve* c); -#endif /*------------------------------------------------------------------------*/ /** \brief Ajoute à la liste les entités de niveaux inférieurs @@ -161,9 +149,7 @@ class Surface: public GeomEntity { * * \param liste d'entity */ -#ifndef SWIG virtual void addAllDownLevelEntity(std::list& l_entity) const; -#endif /*------------------------------------------------------------------------*/ /** \brief retourne un point sur l'objet au centre si possible @@ -193,20 +179,14 @@ class Surface: public GeomEntity { /*------------------------------------------------------------------------*/ /** Ajoute le groupe parmis ceux auxquels appartient la surface */ -#ifndef SWIG virtual void add(Group::Group2D* grp); -#endif /** Retire le groupe parmis ceux auxquels appartient la surface */ -#ifndef SWIG virtual void remove(Group::Group2D* grp); -#endif /** Recherche le groupe parmis ceux auxquels appartient la surface * return vrai si trouvé */ -#ifndef SWIG virtual bool find(Group::Group2D* grp); -#endif /// Retourne les noms des groupes auxquels appartient cette entité virtual void getGroupsName (std::vector& gn) const; @@ -217,9 +197,6 @@ class Surface: public GeomEntity { /// Retourne la liste des groupes 2D auxquels appartient cette entité virtual const std::vector& getGroups() const {return m_groups;} - /// Affecte une nouvelle liste des groupes auxquels appartient cette entité - virtual void setGroups(std::vector& grp); - /// Retourne le nombre de groupes virtual int getNbGroups() const; @@ -233,40 +210,16 @@ class Surface: public GeomEntity { */ const std::vector& getVolumes() const { return m_volumes; } - /*------------------------------------------------------------------------*/ - /// retourne la liste des faces topologiques communes qui pointent sur cette surface - virtual void get(std::vector& cofaces); - - /// retourne la liste des arêtes topologiques communes qui pointent sur cette surface - virtual void get(std::vector& coedges); - - /// retourne la liste des sommets topologiques qui pointent sur cette surface - virtual void get(std::vector& vertices); - /*------------------------------------------------------------------------*/ /** \brief détruit l'objet */ -#ifndef SWIG virtual void setDestroyed(bool b); -#endif /*------------------------------------------------------------------------*/ /** \brief indique si la surface est un plan ou pas */ virtual bool isPlanar() const; - /*------------------------------------------------------------------------*/ - /** \brief Fournit une représentation textuelle de l'entité. - * \param true si l'entité fourni la totalité de sa description, false si - * elle ne fournit que les informations non calculées (objectif : - * optimisation) - * \return Description, à détruire par l'appelant. - */ -#ifndef SWIG - virtual Mgx3D::Utils::SerializedRepresentation* getDescription ( - bool alsoComputed) const; -#endif - private: std::vector m_curves; std::vector m_volumes; diff --git a/src/Core/protected/Geom/Vertex.h b/src/Core/protected/Geom/Vertex.h index 65574cf6..4ccce8e8 100644 --- a/src/Core/protected/Geom/Vertex.h +++ b/src/Core/protected/Geom/Vertex.h @@ -6,6 +6,7 @@ #include /*----------------------------------------------------------------------------*/ #include "Geom/GeomEntity.h" +#include "Services/MementoService.h" #include "Utils/Point.h" /*----------------------------------------------------------------------------*/ namespace Mgx3D { @@ -13,9 +14,6 @@ namespace Mgx3D { namespace Group { class Group0D; } -namespace Topo { -class Vertex; -} /*----------------------------------------------------------------------------*/ namespace Geom { class Curve; @@ -29,7 +27,7 @@ class GeomProperty; */ class Vertex: public GeomEntity { - friend class MementoManager; + friend class Services::MementoService; static const char* typeNameGeomVertex; public: @@ -43,10 +41,9 @@ class Vertex: public GeomEntity { * \param gprop les propriétés associées à la courbe * \param compProp les propriétés de calcul */ -#ifndef SWIG Vertex(Internal::Context& ctx, Utils::Property* prop, Utils::DisplayProperties* disp, GeomProperty* gprop, TopoDS_Vertex& shape); -#endif + const TopoDS_Vertex& getOCCVertex() const { return m_occ_vertex; } virtual void apply(std::function const& lambda) const; @@ -68,24 +65,10 @@ class Vertex: public GeomEntity { */ int getDim() const {return 0;} - /*------------------------------------------------------------------------*/ - /** \brief Fournit une représentation textuelle de l'entité. - * \param true si l'entité fourni la totalité de sa description, false si - * elle ne fournit que les informations non calculées (objectif : - * optimisation) - * \return Description, à détruire par l'appelant. - */ -#ifndef SWIG - virtual Mgx3D::Utils::SerializedRepresentation* getDescription ( - bool alsoComputed) const; -#endif - /*------------------------------------------------------------------------*/ /** \brief Fournit un résumé textuel de l'entité. */ -#ifndef SWIG virtual std::string getSummary ( ) const; -#endif /*------------------------------------------------------------------------*/ /** \brief Calcule l'aire d'une entité: Pour une courbe, c'est la @@ -108,18 +91,12 @@ class Vertex: public GeomEntity { */ const std::vector& getCurves() const {return m_curves;} - /*------------------------------------------------------------------------*/ - /// retourne la liste des sommets topologiques qui pointent sur cette courbe - virtual void get(std::vector& vertices); - /*------------------------------------------------------------------------*/ /** \brief Ajoute c comme courbe incidente * * \param c un pointeur sur une courbe */ -#ifndef SWIG void add(Curve* c); -#endif /*------------------------------------------------------------------------*/ /** \brief Supprime c de la liste des courbes incidentes. Si c n'apparait @@ -127,9 +104,7 @@ class Vertex: public GeomEntity { * * \param v un pointeur sur un volume */ -#ifndef SWIG void remove(Curve* c); -#endif /*------------------------------------------------------------------------*/ /** \brief retourne un point sur l'objet au centre si possible @@ -181,30 +156,22 @@ class Vertex: public GeomEntity { /*------------------------------------------------------------------------*/ /** \brief Surcharge pour l'écriture dans les flux */ -#ifndef SWIG friend std::ostream& operator<<(std::ostream& str, const Vertex& v); /*------------------------------------------------------------------------*/ /** \brief Surcharge pour l'écriture dans les flux */ friend TkUtil::UTF8String& operator<<(TkUtil::UTF8String& str, const Vertex& v); -#endif /*------------------------------------------------------------------------*/ /** Ajoute le groupe parmis ceux auxquels appartient le sommet */ -#ifndef SWIG void add(Group::Group0D* grp); -#endif /** Retire le groupe parmis ceux auxquels appartient le sommet */ -#ifndef SWIG void remove(Group::Group0D* grp); -#endif /** Recherche le groupe parmis ceux auxquels appartient le sommet * return vrai si trouvé */ -#ifndef SWIG bool find(Group::Group0D* grp); -#endif /// Retourne les noms des groupes auxquels appartient cette entité virtual void getGroupsName (std::vector& gn) const; @@ -215,18 +182,13 @@ class Vertex: public GeomEntity { /// Retourne la liste des groupes auxquels appartient cette entité virtual const std::vector& getGroups() const {return m_groups;} - /// Affecte une nouvelle liste des groupes auxquels appartient cette entité - virtual void setGroups(std::vector& grp); - /// Retourne le nombre de groupes virtual int getNbGroups() const; /*------------------------------------------------------------------------*/ /** \brief détruit l'objet */ -#ifndef SWIG virtual void setDestroyed(bool b); -#endif private: /// accès aux courbes incidentes diff --git a/src/Core/protected/Geom/Volume.h b/src/Core/protected/Geom/Volume.h index c69db296..5c73d69c 100644 --- a/src/Core/protected/Geom/Volume.h +++ b/src/Core/protected/Geom/Volume.h @@ -2,6 +2,7 @@ #define MGX3D_GEOM_VOLUME_H_ /*----------------------------------------------------------------------------*/ #include "Geom/GeomEntity.h" +#include "Services/MementoService.h" /*----------------------------------------------------------------------------*/ #include /*----------------------------------------------------------------------------*/ @@ -12,12 +13,6 @@ namespace Mgx3D { namespace Group { class Group3D; } -namespace Topo { -class Block; -class CoFace; -class CoEdge; -class Vertex; -} /*----------------------------------------------------------------------------*/ namespace Geom { @@ -29,9 +24,8 @@ class GeomProperty; * géométrique */ class Volume: public GeomEntity { - + friend class Services::MementoService; friend class GeomModificationBaseClass; - friend class MementoManager; static const char* typeNameGeomVolume; public: @@ -45,10 +39,9 @@ class Volume: public GeomEntity { * \param gprop les propriétés associées au volume * \param compProp les propriétés de calcul */ -#ifndef SWIG Volume(Internal::Context& ctx, Utils::Property* prop, Utils::DisplayProperties* disp, GeomProperty* gprop, TopoDS_Shape& shape); -#endif + const TopoDS_Shape& getOCCShape() const { return m_occ_shape; } virtual void apply(std::function const& lambda) const; @@ -93,19 +86,12 @@ class Volume: public GeomEntity { */ virtual const std::vector& getSurfaces() const {return m_surfaces;} - /*------------------------------------------------------------------------*/ - /** \brief Fournit l'accès aux blocs topologiques qui pointent sur ce volume - */ - virtual void get(std::vector& blocs) const; - /*------------------------------------------------------------------------*/ /** \brief Ajoute s comme surface incidente * * \param s un pointeur sur une surface */ -#ifndef SWIG void add(Surface* s); -#endif /*------------------------------------------------------------------------*/ /** \brief Supprime s de la liste des surfaces incidentes. Si s n'apparait @@ -113,9 +99,7 @@ class Volume: public GeomEntity { * * \param s un pointeur sur une surface */ -#ifndef SWIG void remove(Surface* s); -#endif /*------------------------------------------------------------------------*/ /** \brief Ajoute à la liste les entités de niveaux inférieurs @@ -123,9 +107,7 @@ class Volume: public GeomEntity { * * \param liste d'entity */ -#ifndef SWIG virtual void addAllDownLevelEntity(std::list& l_entity) const; -#endif /*------------------------------------------------------------------------*/ /** \brief retourne un point sur l'objet au centre si possible @@ -155,20 +137,14 @@ class Volume: public GeomEntity { /*------------------------------------------------------------------------*/ /** Ajoute le groupe parmis ceux auxquels appartient le volume */ -#ifndef SWIG void add(Group::Group3D* grp); -#endif /** Retire le groupe parmis ceux auxquels appartient le volume */ -#ifndef SWIG void remove(Group::Group3D* grp); -#endif /** Recherche le groupe parmis ceux auxquels appartient le volume * return vrai si trouvé */ -#ifndef SWIG bool find(Group::Group3D* grp); -#endif /// Retourne les noms des groupes auxquels appartient cette entité virtual void getGroupsName (std::vector& gn) const; @@ -179,30 +155,13 @@ class Volume: public GeomEntity { /// Retourne la liste des groupes 3D auxquels appartient cette entité virtual const std::vector& getGroups() const {return m_groups;} - /// Affecte une nouvelle liste des groupes auxquels appartient cette entité - virtual void setGroups(std::vector& grp); - /// Retourne le nombre de groupes virtual int getNbGroups() const; /*------------------------------------------------------------------------*/ /** \brief détruit l'objet */ -#ifndef SWIG virtual void setDestroyed(bool b); -#endif - - /*------------------------------------------------------------------------*/ - /** \brief Fournit une représentation textuelle de l'entité. - * \param true si l'entité fourni la totalité de sa description, false si - * elle ne fournit que les informations non calculées (objectif : - * optimisation) - * \return Description, à détruire par l'appelant. - */ -#ifndef SWIG - virtual Mgx3D::Utils::SerializedRepresentation* getDescription ( - bool alsoComputed) const; -#endif private: /// surfaces incidentes au volume diff --git a/src/Core/protected/Internal/EntitiesHelper.h b/src/Core/protected/Internal/EntitiesHelper.h index ab92ff60..28a1ec14 100644 --- a/src/Core/protected/Internal/EntitiesHelper.h +++ b/src/Core/protected/Internal/EntitiesHelper.h @@ -101,10 +101,6 @@ class EntitiesHelper //@} // Utilitaires concernant les noms des entités. - - /// Retourne vrai si l'une des entités géométriques a un lien sur une entité topologique - static bool hasTopoRef(std::vector& entities); - /** Conversion d'une liste de commandes en une liste de lignes de scripts * sans avoir de noms qui apparaissent mais juste des références sur les objets créés par les commandes précédentes */ diff --git a/src/Core/protected/Services/DescriptionService.h b/src/Core/protected/Services/DescriptionService.h new file mode 100644 index 00000000..e620a1ad --- /dev/null +++ b/src/Core/protected/Services/DescriptionService.h @@ -0,0 +1,45 @@ +#ifndef _DESCRIPTION_SERVICE_H_ +#define _DESCRIPTION_SERVICE_H_ + +#include "Utils/Entity.h" +#include "Utils/SerializedRepresentation.h" +#include "Geom/GeomEntityVisitor.h" + +namespace Mgx3D::Geom +{ + class GeomEntity; +} + +/** + * - voir si alsoComputed est vraiment utile, pas réussi à comprendre comment Qt le passe à vrai + * + */ +namespace Mgx3D::Services +{ + class DescriptionService : public Geom::ConstGeomEntityVisitor + { + public: + static Utils::SerializedRepresentation* getDescription(const Geom::GeomEntity* e, const bool alsoComputed); + + DescriptionService(const bool alsoComputed); + ~DescriptionService() override = default; + void visit(const Geom::Vertex*) override; + void visit(const Geom::Curve*) override; + void visit(const Geom::Surface*) override; + void visit(const Geom::Volume*) override; + + private: + void visitEntity(const Utils::Entity*); + void visitGeomEntity(const Geom::GeomEntity*); + + template + void buildSerializedRepresentation(Utils::SerializedRepresentation &description, const std::string &title, const Utils::EntitySet elements) const; + template + void buildSerializedRepresentation(Utils::SerializedRepresentation &description, const std::string &title, const std::vector elements) const; + + bool m_also_computed; + Utils::SerializedRepresentation *m_representation; + }; +} + +#endif /* _DESCRIPTION_SERVICE_H_ */ diff --git a/src/Core/protected/Services/InfoService.h b/src/Core/protected/Services/InfoService.h new file mode 100644 index 00000000..a6d13b5f --- /dev/null +++ b/src/Core/protected/Services/InfoService.h @@ -0,0 +1,18 @@ +#ifndef _INFO_SERVICE_H_ +#define _INFO_SERVICE_H_ + +#include "Geom/GeomInfo.h" + +namespace Mgx3D::Geom { + class GeomEntity; +} + +namespace Mgx3D::Services +{ + struct InfoService + { + static Geom::GeomInfo getInfos(const Geom::GeomEntity*); + }; +} + +#endif /* _INFO_SERVICE_H_ */ diff --git a/src/Core/protected/Services/MementoService.h b/src/Core/protected/Services/MementoService.h new file mode 100644 index 00000000..788afddb --- /dev/null +++ b/src/Core/protected/Services/MementoService.h @@ -0,0 +1,100 @@ +#ifndef _MEMENTO_SERVICE_H_ +#define _MEMENTO_SERVICE_H_ + +#include +#include +#include + +namespace Mgx3D +{ + namespace Geom + { + class GeomProperty; + class GeomEntity; + class Vertex; + class Curve; + class Surface; + class Volume; + } + + namespace Topo + { + class TopoEntity; + } + + namespace Group + { + class Group0D; + class Group1D; + class Group2D; + class Group3D; + } +} + +namespace Mgx3D::Services +{ + /*----------------------------------------------------------------------------*/ + /** + * \class Memento + * \brief Classe permettant le stockage des informations caractérisant une + * entité géométrique dans le cadre du undo/redo. + * + * Par défaut, le système de commandes de Mgx3D permet de stocker les + * entités de Magix3D qui ont été supprimées, modifiées et/ou ajoutées. + * Dans le cas d'entités que l'on modifie, c'est de leur responsabilité + * de stocker leurs "modifications". La classe Memento joue + * ce rôle pour les entités géométriques. + * + * Dans le cadre du pattern Mémento, la classe Memento joue + * le rôle de Mémento, les classes filles de GeomEntity jouent le rôle + * de créateurs et les classes de Commandes géométriques ayant besoin + * de ce type d'informations de sauvegarde jouent le rôle de Demandeur + * et de Gardien des mémentos. + * + * Pour le moment, une seule classe de Mémento géométrique est mise en + * place (celle-ci). Il est possible qu'il soit nécessaire de + * spécialiser le mémento pour chaque type d'entités géométriques + * (sommets, courbes, surfaces, volumes) + * + */ + struct Memento + { + std::vector topo_entities; + std::vector volumes; + std::vector surfaces; + std::vector curves; + std::vector vertices; + + /// Listes des groupes 1D auxquels appartient cette courbe + std::vector groups0D; + std::vector groups1D; + std::vector groups2D; + std::vector groups3D; + + /* ancienne représentation géométrique des entités que l'on a modifiées */ + std::vector occ_shapes; + + /* ancienne propriétés des entités que l'on a modifiées. Il + * est de la responsabilité de l'objet de les détruire */ + Geom::GeomProperty *property = nullptr; + }; + + class MementoService + { + public: + const Memento createMemento(const Geom::GeomEntity *e) const; + void saveMemento(Geom::GeomEntity *e, const Memento &mem); + void saveMemento(Geom::GeomEntity *e) { saveMemento(e, createMemento(e)); } + void permMementos(); + + private: + void setFromMemento(Geom::GeomEntity *e, const Memento &mem); + + /** pour les entitiés géométriques modifiées lors de l'opération, on + * stocke leur "état interne" sous forme de mémento. Ce stockage est de la + * responsabilité de chaque entité */ + std::map m_mementos; + }; +} + +#endif /* _MEMENTO_SERVICE_H_ */ diff --git a/src/Core/protected/Topo/CoFace.h b/src/Core/protected/Topo/CoFace.h index 719ab342..9aeb5a0d 100644 --- a/src/Core/protected/Topo/CoFace.h +++ b/src/Core/protected/Topo/CoFace.h @@ -203,7 +203,7 @@ class CoFace : public TopoEntity { * Sont données les nouvelles arêtes et les sommets le long de la coupe */ - void splitOgrid(eDirOnCoFace dir, + std::vector splitOgrid(eDirOnCoFace dir, std::vector& edges0, std::vector& edges1, std::vector& edges2, diff --git a/src/Core/protected/Topo/CommandSplitFaces.h b/src/Core/protected/Topo/CommandSplitFaces.h index fbe14064..ffafe4d6 100644 --- a/src/Core/protected/Topo/CommandSplitFaces.h +++ b/src/Core/protected/Topo/CommandSplitFaces.h @@ -19,68 +19,50 @@ class CommandSplitFaces: public Topo::CommandEditTopo { public: /*------------------------------------------------------------------------*/ - /** \brief Constructeur pour découper une liste de faces (dont on ne garde que celles 2D structurées) + /** \brief Constructeur pour découper une liste de faces (dont on ne garde que celles structurées) * * \param c le contexte * \param cofaces les faces communes à découper * \param arete l'arête qui sert à déterminer la direction de la coupe structurée * \param ratio_dec un paramètre pour déterminer la position du sommet sur l'arête * \param ratio_ogrid un autre paramètre pour positionner le sommet du ogrid en cas de rencontre avec une face dégénérée + * \param project_on_meshing_edges activation ou non de la projection des sommets issus de la coupe sur la discrétisation initiale */ - CommandSplitFaces(Internal::Context& c, std::vector &cofaces, CoEdge* arete, double ratio_dec, double ratio_ogrid); + CommandSplitFaces(Internal::Context& c, std::vector &cofaces, CoEdge* arete, double ratio_dec, double ratio_ogrid, bool project_on_meshing_edges=true); /*------------------------------------------------------------------------*/ - /** \brief Constructeur pour découper une liste de faces (dont on ne garde que celles 2D structurées) + /** \brief Constructeur pour découper une liste de faces (dont on ne garde que celles structurées) * * \param c le contexte * \param cofaces les faces communes à découper * \param arete l'arête qui sert à déterminer la direction de la coupe structurée * \param pt un point qui donnera un paramètre pour déterminer la position du sommet sur l'arête par projection sur cette dernière * \param ratio_ogrid un autre paramètre pour positionner le sommet du ogrid en cas de rencontre avec une face dégénérée + * \param project_on_meshing_edges activation ou non de la projection des sommets issus de la coupe sur la discrétisation initiale */ - CommandSplitFaces(Internal::Context& c, std::vector &cofaces, CoEdge* arete, const Utils::Math::Point& pt, double ratio_ogrid); + CommandSplitFaces(Internal::Context& c, std::vector &cofaces, CoEdge* arete, const Utils::Math::Point& pt, double ratio_ogrid, bool project_on_meshing_edges=true); /*------------------------------------------------------------------------*/ - /** \brief Constructeur pour découper toutes les faces 2D structurées disponibles + /** \brief Constructeur pour découper toutes les faces structurées disponibles * * \param c le contexte * \param arete l'arête qui sert à déterminer la direction de la coupe structurée * \param ratio_dec un paramètre pour déterminer la position du sommet sur l'arête * \param ratio_ogrid un autre paramètre pour positionner le sommet du ogrid en cas de rencontre avec une face dégénérée + * \param project_on_meshing_edges activation ou non de la projection des sommets issus de la coupe sur la discrétisation initiale */ - CommandSplitFaces(Internal::Context& c, CoEdge* arete, double ratio_dec, double ratio_ogrid); + CommandSplitFaces(Internal::Context& c, CoEdge* arete, double ratio_dec, double ratio_ogrid, bool project_on_meshing_edges=true); /*------------------------------------------------------------------------*/ - /** \brief Constructeur pour découper toutes les faces 2D structurées disponibles + /** \brief Constructeur pour découper toutes les faces structurées disponibles * * \param c le contexte * \param arete l'arête qui sert à déterminer la direction de la coupe structurée * \param pt un point qui donnera un paramètre pour déterminer la position du sommet sur l'arête par projection sur cette dernière * \param ratio_ogrid un autre paramètre pour positionner le sommet du ogrid en cas de rencontre avec une face dégénérée - */ - CommandSplitFaces(Internal::Context& c, CoEdge* arete, const Utils::Math::Point& pt, double ratio_ogrid); - - /*------------------------------------------------------------------------*/ - /** \brief Constructeur pour une face (2D ou 3D) à découper - * - * \param c le contexte - * \param coface la face commune à découper - * \param arete celle qui sert à déterminer la direction de la coupe structurée - * \param ratio_dec un paramètre pour déterminer la position du sommet sur l'arête * \param project_on_meshing_edges activation ou non de la projection des sommets issus de la coupe sur la discrétisation initiale */ - CommandSplitFaces(Internal::Context& c, CoFace* coface, CoEdge* coedge, double ratio_dec, bool project_on_meshing_edges); - - /*------------------------------------------------------------------------*/ - /** \brief Constructeur pour une face (2D ou 3D) à découper - * - * \param c le contexte - * \param coface la face commune à découper - * \param arete celle qui sert à déterminer la direction de la coupe structurée - * \param pt un point qui donnera un paramètre pour déterminer la position du sommet sur l'arête par projection sur cette dernière - * \param project_on_meshing_edges activation ou non de la projection des sommets issus de la coupe sur la discrétisation initiale - */ - CommandSplitFaces(Internal::Context& c, CoFace* coface, CoEdge* coedge, const Utils::Math::Point& pt, bool project_on_meshing_edges); + CommandSplitFaces(Internal::Context& c, CoEdge* arete, const Utils::Math::Point& pt, double ratio_ogrid, bool project_on_meshing_edges=true); /*------------------------------------------------------------------------*/ /** \brief Destructeur @@ -105,13 +87,13 @@ class CommandSplitFaces: public Topo::CommandEditTopo { virtual void getPreviewRepresentation(Utils::DisplayRepresentation& dr); private: - /// stocke les faces communes 2D structurées parmi celles données en paramètre - void init2D(std::vector &cofaces); + /// stocke les faces communes structurées parmi celles données en paramètre + void init(std::vector &cofaces); /// Vérification de la face topologique (pas d'arête colinéaires ...) void verif(Topo::CoFace* coface); - /// les faces communes 2D structurées à découper + /// les faces communes structurées à découper std::vector m_cofaces; /// l'arête qui sert à déterminer la direction de la coupe structurée @@ -125,6 +107,11 @@ class CommandSplitFaces: public Topo::CommandEditTopo { /// activation ou non de la projection des sommets créés sur la discrétisation initiale bool m_project_on_meshing_edges; + + bool + findFaceUnmarkedWithVertexMarked(std::set &filtre_faces, std::set &filtre_vertices, + CoFace *&face, + Vertex *&noeud); }; /*----------------------------------------------------------------------------*/ } // end namespace Topo diff --git a/src/Core/protected/Topo/TopoInfo.h b/src/Core/protected/Topo/TopoInfo.h index b1193a77..c03f7994 100644 --- a/src/Core/protected/Topo/TopoInfo.h +++ b/src/Core/protected/Topo/TopoInfo.h @@ -1,63 +1,35 @@ -/*----------------------------------------------------------------------------*/ -/* - * TopoInfo.h - * - * Created on: 14/3/2019 - * Author: Eric B - */ -/*----------------------------------------------------------------------------*/ #ifndef TOPOINFO_H_ #define TOPOINFO_H_ -/*----------------------------------------------------------------------------*/ + #include #include -/*----------------------------------------------------------------------------*/ -namespace Mgx3D { -/*----------------------------------------------------------------------------*/ -namespace Geom { -class GeomEntity; -} -/*----------------------------------------------------------------------------*/ -namespace Topo { -/*----------------------------------------------------------------------------*/ -class Vertex; -class CoEdge; -class Edge; -class CoFace; -class Face; -class Block; -/*----------------------------------------------------------------------------*/ -class TopoInfo{ -public: - std::string name; - int dimension; +namespace Mgx3D::Topo +{ + struct TopoInfo + { + std::string name; + int dimension; + std::string geom_entity; + + std::vector vertices() const { return _vertices; } + std::vector coedges() const { return _coedges; } + std::vector edges() const { return _edges; } + std::vector cofaces() const { return _cofaces; } + std::vector faces() const { return _faces; } + std::vector blocks() const { return _blocks; } + std::vector groups() const { return _groups; } + #ifndef SWIG - std::vector incident_vertices; - std::vector incident_coedges; - std::vector incident_edges; - std::vector incident_cofaces; - std::vector incident_faces; - std::vector incident_blocks; - Geom::GeomEntity* geom_entity; - std::vector groups_name; + std::vector _vertices; + std::vector _coedges; + std::vector _edges; + std::vector _cofaces; + std::vector _faces; + std::vector _blocks; + std::vector _groups; #endif - - std::vector vertices() const; - std::vector coedges() const; - std::vector edges() const; - std::vector cofaces() const; - std::vector faces() const; - std::vector blocks() const; - std::string geomEntity() const; - std::vector groupsName() const; -}; -/*----------------------------------------------------------------------------*/ -} // end namespace Topo -/*----------------------------------------------------------------------------*/ -} // end namespace Mgx3D -/*----------------------------------------------------------------------------*/ + }; +} #endif /* TOPOINFO_H_ */ -/*----------------------------------------------------------------------------*/ - diff --git a/src/Core/protected/Topo/TopoManager.h b/src/Core/protected/Topo/TopoManager.h index 19a73015..80833cd5 100644 --- a/src/Core/protected/Topo/TopoManager.h +++ b/src/Core/protected/Topo/TopoManager.h @@ -1,15 +1,4 @@ /*----------------------------------------------------------------------------*/ -/** \file TopoManager.h - * - * \author Eric Brière de l'Isle - * - * \date 2/12/2010 - * - * Modified on: 23/02/2022 - * Author: Simon C - * ajout de la fonction de création de blocs par extrusion de faces topologiques - */ -/*----------------------------------------------------------------------------*/ #ifndef TOPO_MANAGER_H_ #define TOPO_MANAGER_H_ /*----------------------------------------------------------------------------*/ @@ -821,21 +810,21 @@ class TopoManager final : public Internal::CommandCreator { #endif /*------------------------------------------------------------------------*/ - /** \brief Découpe des faces structurées 2D en deux + /** \brief Découpe des faces structurées en deux * * On utilise une arête et un ratio pour positionner un premier sommet * qui va être inséré sur l'arête. * Les autres arêtes parallèles sont aussi découpées avec le même ratio. - * Si ratio_ogrid vaut 0, alors le tracé de l'ogrid peut passer par l'axe si une face n'a que 3 côté, + * Si ratio_ogrid vaut 0, alors le tracé de l'ogrid peut passer par l'axe si une face n'a que 3 côtés, * sinon on découpe la face en 3 (ogrid en 2D) avec un sommet placé avec ce ratio entre le sommet dans * le prolongement sur l'axe et le sommet à l'entrée dans la face. */ Mgx3D::Internal::M3DCommandResult* - splitFaces(std::vector &cofaces_names, std::string narete, const double& ratio_dec, const double& ratio_ogrid); + splitFaces(std::vector &cofaces_names, std::string narete, const double& ratio_dec, const double& ratio_ogrid, bool project_on_meshing_edge = true); #ifndef SWIG Mgx3D::Internal::M3DCommandResult* - splitFaces(std::vector &cofaces, CoEdge* arete, const double& ratio_dec, const double& ratio_ogrid); + splitFaces(std::vector &cofaces, CoEdge* arete, const double& ratio_dec, const double& ratio_ogrid, bool project_on_meshing_edge); #endif /** \brief Découpe des faces structurées 2D en deux suivant un point à projeter @@ -848,36 +837,38 @@ class TopoManager final : public Internal::CommandCreator { * le prolongement sur l'axe et le sommet à l'entrée dans la face. */ Mgx3D::Internal::M3DCommandResult* - splitFaces(std::vector &cofaces_names, std::string narete, const Point& pt, const double& ratio_ogrid); + splitFaces(std::vector &cofaces_names, std::string narete, const Point& pt, const double& ratio_ogrid, bool project_on_meshing_edge = true); #ifndef SWIG Mgx3D::Internal::M3DCommandResult* - splitFaces(std::vector &cofaces, CoEdge* arete, const Point& pt, const double& ratio_ogrid); + splitFaces(std::vector &cofaces, CoEdge* arete, const Point& pt, const double& ratio_ogrid, bool project_on_meshing_edge); #endif /** \brief Découpe toutes les faces structurées 2D en deux * \see splitFaces */ Mgx3D::Internal::M3DCommandResult* - splitAllFaces(std::string narete, const double& ratio_dec, const double& ratio_ogrid); + splitAllFaces(std::string narete, const double& ratio_dec, const double& ratio_ogrid, bool project_on_meshing_edge = true); #ifndef SWIG Mgx3D::Internal::M3DCommandResult* - splitAllFaces(CoEdge* arete, const double& ratio_dec, const double& ratio_ogrid); + splitAllFaces(CoEdge* arete, const double& ratio_dec, const double& ratio_ogrid, bool project_on_meshing_edge); #endif - /** \brief Découpe toutes les faces structurées 2D en deux suivant un point à projeter + /** \brief Découpe toutes les faces structurées en deux suivant un point à projeter * \see splitFaces */ Mgx3D::Internal::M3DCommandResult* - splitAllFaces(std::string narete, const Point& pt, const double& ratio_ogrid); + splitAllFaces(std::string narete, const Point& pt, const double& ratio_ogrid, bool project_on_meshing_edge = true); #ifndef SWIG Mgx3D::Internal::M3DCommandResult* - splitAllFaces(CoEdge* arete, const Point& pt, const double& ratio_ogrid); + splitAllFaces(CoEdge* arete, const Point& pt, const double& ratio_ogrid, bool project_on_meshing_edge); #endif /** \brief Découpage d'une face structurée 2D ou 3D en deux suivant un ratio + * + * OBSOLETE: Issue201 - Homogénéisation de l'API : utiliser splitFaces * * On utilise une arête et un ratio pour positionner un premier sommet * qui va être inséré sur l'arête. @@ -892,13 +883,15 @@ class TopoManager final : public Internal::CommandCreator { #endif /** \brief Découpage d'une face structurée 2D ou 3D en deux suivant un point à projeter + * + * OBSOLETE: Issue201 - Homogénéisation de l'API : utiliser splitFaces * * On utilise une arête et un point que l'on projette sur cette arête pour positionner un premier sommet * qui va être inséré sur l'arête. * L'autre arête parallèle est aussi découpée avec le même ratio induit de la première coupe. */ Mgx3D::Internal::M3DCommandResult* - splitFace(std::string coface_name, std::string narete, const Point& pt, bool project_on_meshing_edges = true); + splitFace(std::string coface_name, std::string narete, const Point& pt, bool project_on_meshing_edges); #ifndef SWIG Mgx3D::Internal::M3DCommandResult* @@ -1896,6 +1889,30 @@ class TopoManager final : public Internal::CommandCreator { alignVerticesOnSurface(Geom::GeomEntity* surface, Vertex* vertex, const Point &pnt1, const Point &pnt2); #endif +#ifndef SWIG + /// Retourne les entités topologiques associées, léve une exception si aucune + const std::vector& getRefTopos(const Geom::GeomEntity* ge); + /// Ajoute une association Geom-->Topo + void addRefTopo(const Geom::GeomEntity* ge, TopoEntity* te); + /// Positionne les associations Geom-->Topo + void setRefTopos(const Geom::GeomEntity* ge, const std::vector& tes); + /// Enlève une association Geom-->Topo + void removeRefTopo(const Geom::GeomEntity* ge, TopoEntity* te); + /// Retourne les entités topologiques filtrées, léve une exception si aucune + template + std::vector getFilteredRefTopos(const Geom::GeomEntity* ge) + { + static_assert(std::is_base_of::value, "T doit hériter de TopoEntity"); + std::vector result; + for (Topo::TopoEntity* te : getRefTopos(ge)) { + if (T* casted = dynamic_cast(te)) { + result.push_back(casted); + } + } + return result; + } +#endif + private: /** Recherche un vecteur d'entités topologiques suivant leur nom, * lève une exception en cas d'erreur. @@ -1926,6 +1943,9 @@ class TopoManager final : public Internal::CommandCreator { /// Nombre de bras par défaut pour une arête int m_defaultNbMeshingEdges; + + /// Relation Geom --> Topo + std::map> m_geom_associations; }; /*----------------------------------------------------------------------------*/ } // end namespace Topo diff --git a/src/QtComponents/QtMgx3DMainWindow.cpp b/src/QtComponents/QtMgx3DMainWindow.cpp index 57c10635..519ea90e 100644 --- a/src/QtComponents/QtMgx3DMainWindow.cpp +++ b/src/QtComponents/QtMgx3DMainWindow.cpp @@ -18,6 +18,7 @@ #include "Internal/Resources.h" #include "Internal/CommandInternal.h" #include "Internal/EntitiesHelper.h" +#include "Internal/InternalPreferences.h" #include "Internal/PythonWriter.h" #include "QtComponents/QtMgx3DApplication.h" #include "QtComponents/QtMgx3DMainWindow.h" @@ -85,7 +86,6 @@ #include "QtComponents/QtTopologySplitBlockWithOGridAction.h" #include "QtComponents/QtTopologyExtendSplitBlockAction.h" #include "QtComponents/QtTopologyExtendSplitFaceAction.h" -#include "QtComponents/QtTopologySplitFaceAction.h" #include "QtComponents/QtTopologySplitFacesAction.h" #include "QtComponents/QtTopologyVerticesAlignmentAction.h" #include "QtComponents/QtTopoEntityDestructionAction.h" @@ -3081,18 +3081,11 @@ void QtMgx3DMainWindow::showReady ( ) // Coupe de faces : QtMgx3DOperationAction *splitFacesAction = new QtTopologySplitFacesAction( - QIcon(":/images/topo_split_faces.png"), QString::fromUtf8("[2D] Découpage de faces selon une arête"), *this, - QString::fromUtf8("Découpage de faces selon une arête (uniquement pour cas 2D).") + QIcon(":/images/topo_split_faces.png"), QString::fromUtf8("Découpage de faces selon une arête"), *this, + QString::fromUtf8("Découpage de faces selon une arête.") ); registerOperationAction( *splitFacesAction, QtMgx3DOperationsPanel::TOPO_FACE_OPERATION); - QtMgx3DOperationAction *splitFaceAction = - new QtTopologySplitFaceAction( - QIcon(":/images/topo_split_face.png"), QString::fromUtf8("Découpage d'une face selon une arête"), *this, - QString::fromUtf8("Découpage d'une face selon une arête.") - ); - registerOperationAction( - *splitFaceAction, QtMgx3DOperationsPanel::TOPO_FACE_OPERATION); QtMgx3DOperationAction *splitFaceWithOGridAction = new QtTopologySplitFaceWithOGridAction( QIcon(":/images/topo_split_face_with_ogrid.png"), @@ -5190,47 +5183,45 @@ void QtMgx3DMainWindow::savePythonConsole (bool withEnv) } // QtMgx3DMainWindow::savePythonConsole - void QtMgx3DMainWindow::preferencesCallback() - { - BEGIN_QT_TRY_CATCH_BLOCK +void QtMgx3DMainWindow::preferencesCallback() +{ + BEGIN_QT_TRY_CATCH_BLOCK - QtMgx3DApplication::editConfiguration(this, UTF8String("Magix 3D : préférences utilisateur.", Charset::UTF_8)); + // Mémorisation des couleurs pour entités topologiques : on actualisera lesdites entités topologiques si leur couleur est modifiée : + const TkUtil::Color oldTopoColorWithoutProj (Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getBlue ( )); + const TkUtil::Color oldTopoColorWith0DProj (Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getBlue ( )); + const TkUtil::Color oldTopoColorWith1DProj (Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getBlue ( )); + const TkUtil::Color oldTopoColorWith2DProj (Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getBlue ( )); + const TkUtil::Color oldTopoColorWith3DProj (Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getBlue ( )); - // Les préférences ont peut être été modifiées => on actualise ce qui doit - // l'être : - // Interacteur : - if (0 != _graphicalWidget) - _graphicalWidget->updateConfiguration(); - - // Vue 3D : - _actions._displayTrihedronAction->setChecked( - Resources::instance()._displayTrihedron.getValue()); -// _actions._displayLandmarkAction->setChecked ( -// Resources::instance ( )._displayLandmark.getValue ( )); - _actions._displayFocalPointAction->setChecked( - Resources::instance()._displayFocalPoint.getValue()); - - // Logs : - Log::TYPE mask = QtMgx3DApplication::getLogsMask(); - getLogDispatcher().setMask(mask); + QtMgx3DApplication::editConfiguration(this, UTF8String("Magix 3D : préférences utilisateur.", Charset::UTF_8)); + + // Les préférences ont peut être été modifiées => on actualise ce qui doit l'être : + // Interacteur : + if (0 != _graphicalWidget) + _graphicalWidget->updateConfiguration(); + + // Vue 3D : + _actions._displayTrihedronAction->setChecked(Resources::instance()._displayTrihedron.getValue()); +// _actions._displayLandmarkAction->setChecked (Resources::instance ( )._displayLandmark.getValue ( )); + _actions._displayFocalPointAction->setChecked(Resources::instance()._displayFocalPoint.getValue()); + + // Logs : + Log::TYPE mask = QtMgx3DApplication::getLogsMask(); + getLogDispatcher().setMask(mask); // Context* context = dynamic_cast(&getContext ( )); // if (0 != context) // { -// context->getStdLogStream ( ).setMask ( -// QtMgx3DApplication::getLogsMask ( )); -// context->getErrLogStream ( ).setMask ( -// QtMgx3DApplication::getLogsMask ( )); +// context->getStdLogStream ( ).setMask (QtMgx3DApplication::getLogsMask ( )); +// context->getErrLogStream ( ).setMask (QtMgx3DApplication::getLogsMask ( )); // } - getLogDispatcher().enableDate( - Resources::instance()._logDate, Resources::instance()._logTime); + getLogDispatcher().enableDate(Resources::instance()._logDate, Resources::instance()._logTime); getLogDispatcher().enableThreadID(Resources::instance()._logThreadID); getLogView().setLogMask(mask); if (0 != _statusView) _statusView->setMask(mask); - if (getActions()._recentFilesCapacity != - Resources::instance()._recentScriptCapacity.getValue()) - updateRecentScriptsURLFifoCapacity( - Resources::instance()._recentScriptCapacity.getValue()); + if (getActions()._recentFilesCapacity != Resources::instance ( )._recentScriptCapacity.getValue ( )) + updateRecentScriptsURLFifoCapacity (Resources::instance ( )._recentScriptCapacity.getValue ( )); // Tester les logs : /* InformationLog i ("Information"); @@ -5255,8 +5246,50 @@ log (t4); log (t5); */ - COMPLETE_QT_TRY_CATCH_BLOCK(true, this, getAppTitle()) - } // QtMgx3DMainWindow::preferencesCallback + const TkUtil::Color currentTopoColorWithoutProj (Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getBlue ( )); + const TkUtil::Color currentTopoColorWith0DProj (Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getBlue ( ));; + const TkUtil::Color currentTopoColorWith1DProj (Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getBlue ( ));; + const TkUtil::Color currentTopoColorWith2DProj (Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getBlue ( ));; + const TkUtil::Color currentTopoColorWith3DProj (Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getBlue ( ));; + const bool updateAll = (currentTopoColorWithoutProj != oldTopoColorWithoutProj); + const bool update3D = (updateAll || (currentTopoColorWith3DProj != oldTopoColorWith3DProj)); + const bool update2D = (update3D || (currentTopoColorWith2DProj != oldTopoColorWith2DProj)); + const bool update1D = (update2D || (currentTopoColorWith1DProj != oldTopoColorWith1DProj)); + const bool update0D = (update1D || (currentTopoColorWith0DProj != oldTopoColorWith0DProj)); + + if (update0D) + { + std::vector vertices; + getContext ( ).getTopoManager ( ).getVertices (vertices); + for (std::vector::iterator itv = vertices.begin ( ); vertices.end ( ) != itv; itv++) + (*itv)->updateDisplayPropertiesColor ( ); + } // if (true == update0D) + if (update1D) + { + std::vector edges; + getContext ( ).getTopoManager ( ).getCoEdges (edges); + for (std::vector::iterator ite = edges.begin ( ); edges.end ( ) != ite; ite++) + (*ite)->updateDisplayPropertiesColor ( ); + } // if (true == update1D) + if (update2D) + { + std::vector faces; + getContext ( ).getTopoManager ( ).getCoFaces (faces); + for (std::vector::iterator itf = faces.begin ( ); faces.end ( ) != itf; itf++) + (*itf)->updateDisplayPropertiesColor ( ); + } // if (true == update2D) + if (update3D) + { + std::vector blocks; + getContext ( ).getTopoManager ( ).getBlocks (blocks); + for (std::vector::iterator itb = blocks.begin ( ); blocks.end ( ) != itb; itb++) + (*itb)->updateDisplayPropertiesColor ( ); + } // if (true == update3D) + if (updateAll || update0D || update1D || update2D || update3D) + getGraphicalWidget ( ).getRenderingManager ( ).updateRepresentations ( ); + + COMPLETE_QT_TRY_CATCH_BLOCK(true, this, getAppTitle()) +} // QtMgx3DMainWindow::preferencesCallback void QtMgx3DMainWindow::editSettingsCallback() diff --git a/src/QtComponents/QtTopologySplitFaceAction.cpp b/src/QtComponents/QtTopologySplitFaceAction.cpp deleted file mode 100644 index c14cbba6..00000000 --- a/src/QtComponents/QtTopologySplitFaceAction.cpp +++ /dev/null @@ -1,567 +0,0 @@ -/** - * \file QtTopologySplitFaceAction.cpp - * \author Charles PIGNEROL - * \date 17/03/2014 - */ - -#include "Internal/Context.h" - -#include "Utils/Common.h" -#include -#include "QtComponents/QtMgx3DMainWindow.h" -#include "QtComponents/QtNumericFieldsFactory.h" -#include "QtComponents/QtTopologySplitFaceAction.h" -#include "Geom/GeomEntity.h" -#include "Topo/CommandSplitFaces.h" -#include "Topo/TopoDisplayRepresentation.h" -#include "Topo/Vertex.h" - -#include -#include -#include - -#include -#include - -using namespace std; -using namespace TkUtil; -using namespace Mgx3D; -using namespace Mgx3D::Utils; -using namespace Mgx3D::Internal; -using namespace Mgx3D::Geom; -using namespace Mgx3D::Topo; -using namespace Mgx3D::Utils; - - -namespace Mgx3D -{ - -namespace QtComponents -{ - - -// =========================================================================== -// LA CLASSE QtTopologySplitFacePanel -// =========================================================================== - -QtTopologySplitFacePanel::QtTopologySplitFacePanel ( - QWidget* parent, const string& panelName, - QtMgx3DMainWindow& mainWindow, QtMgx3DOperationAction* action) - : QtMgx3DOperationPanel ( - parent, mainWindow, action, - QtMgx3DApplication::HelpSystem::instance ( ).splitFaceOperationURL, - QtMgx3DApplication::HelpSystem::instance ( ).splitFaceOperationTag), - _facePanel (0), _edgePanel (0), _cutDefinitionButtonGroup (0), - _ratioTextField (0), _cutPointEntityPanel (0), - _projectVerticesCheckBox (0) -{ - QVBoxLayout* layout = new QVBoxLayout (this); - setLayout (layout); - layout->setContentsMargins (0, 0, 0, 0); - layout->setSpacing (5); - - // Le nom du panneau : - QLabel* label = new QLabel (panelName.c_str ( ), this); - QFont font (label->font ( )); - font.setBold (true); - label->setFont (font); - layout->addWidget (label); - - // La face à découper : - _facePanel = new QtMgx3DEntityPanel ( - this, "", true, "Face :", "", &mainWindow, - SelectionManager::D2, FilterEntity::TopoCoFace); - _facePanel->setToolTip (QString::fromUtf8("Face soumise au découpage.")); - connect (_facePanel, SIGNAL (entitiesAddedToSelection(QString)), - this, SLOT (entitiesAddedToSelectionCallback (QString))); - connect (_facePanel, SIGNAL (entitiesRemovedFromSelection(QString)), - this, SLOT (entitiesRemovedFromSelectionCallback (QString))); - layout->addWidget (_facePanel); - - // L'arête orthogonale au plan de coupe : - _edgePanel = new QtMgx3DEntityPanel ( - this, "", true, "Arête :", "", &mainWindow, - SelectionManager::D1, FilterEntity::TopoCoEdge); - _edgePanel->setToolTip (QString::fromUtf8("Arête orthogonale au plan de coupe.")); - connect (_edgePanel, SIGNAL (entitiesAddedToSelection(QString)), - this, SLOT (entitiesAddedToSelectionCallback (QString))); - connect (_edgePanel, SIGNAL (entitiesRemovedFromSelection(QString)), - this, SLOT (entitiesRemovedFromSelectionCallback (QString))); - layout->addWidget (_edgePanel); - - // La définition de la découpe : - _cutDefinitionButtonGroup = new QButtonGroup (this); - _cutDefinitionButtonGroup->setExclusive (true); - QGridLayout* gridLayout = new QGridLayout ( ); - int row = 0, col = 0; - layout->addLayout (gridLayout); - gridLayout->setContentsMargins (0, 0, 0, 0); - // Par un ratio : - QRadioButton* ratioRadioButton = new QRadioButton ("Ratio :", this); - ratioRadioButton->setChecked (true); - _cutDefinitionButtonGroup->addButton ( - ratioRadioButton, QtTopologySplitFacePanel::CDM_RATIO); - gridLayout->addWidget (ratioRadioButton, row, col++); - _ratioTextField = &QtNumericFieldsFactory::createRatioTextField (this); - _ratioTextField->setValue (0.5); - gridLayout->addWidget (_ratioTextField, row++, col++, 1, 2); - _ratioTextField->setToolTip (QString::fromUtf8("Pourcentage de la longueur de l'arête où est le point situé dans le plan de coupe.")); - connect (_ratioTextField, SIGNAL (textEdited (const QString&)), this, - SLOT (parametersModifiedCallback ( ))); - // Par un point : - col = 0; - QRadioButton* entityRadioButton = new QRadioButton (QString::fromUtf8("Entité :"), this); - _cutDefinitionButtonGroup->addButton ( - entityRadioButton, QtTopologySplitFacePanel::CDM_POINT); - gridLayout->addWidget (entityRadioButton, row, col++); - const FilterEntity::objectType filter = - (FilterEntity::objectType)( - FilterEntity::AllGeom | FilterEntity::TopoVertex); - _cutPointEntityPanel = - new QtMgx3DEntityPanel (this, "", true, "", "", &mainWindow, - SelectionManager::ALL_DIMENSIONS, filter); - _cutPointEntityPanel->setToolTip (QString::fromUtf8("Entité géométrique dont le centre sert de position de découpe, ou sommet topologique.")); - gridLayout->addWidget (_cutPointEntityPanel, row, col++, 1, 2); - connect (_cutPointEntityPanel, SIGNAL (entitiesAddedToSelection(QString)), - this, SLOT (entitiesAddedToSelectionCallback (QString))); - connect (_cutPointEntityPanel, - SIGNAL (entitiesRemovedFromSelection(QString)), - this, SLOT (entitiesRemovedFromSelectionCallback (QString))); - connect (_cutDefinitionButtonGroup, SIGNAL (buttonClicked (int)), - this, SLOT (parametersModifiedCallback ( ))); - connect (_cutDefinitionButtonGroup, SIGNAL (buttonClicked (int)), - this, SLOT (cutDefinitionModifiedCallback ( ))); - double r = ((double)_ratioTextField->sizeHint ( ).width( )) / - entityRadioButton->sizeHint ( ).width( ) + 0.5; - gridLayout->setColumnStretch (0, 1); - gridLayout->setColumnStretch (1, (int)r); - ratioRadioButton->setFixedSize (entityRadioButton->sizeHint ( )); - entityRadioButton->setFixedSize (entityRadioButton->sizeHint ( )); - - // Faut il projeter les sommets créés sur la discrétisation initiale ? - _projectVerticesCheckBox = new QCheckBox ( - "Projeter les sommets créés sur la discrétisation initiale", this); - _projectVerticesCheckBox->setChecked (true); - layout->addWidget (_projectVerticesCheckBox); - connect (_projectVerticesCheckBox, SIGNAL (stateChanged (int)), this, - SLOT (parametersModifiedCallback ( ))); - - addPreviewCheckBox (false); - - layout->addStretch (2); - - CHECK_NULL_PTR_ERROR (_facePanel->getNameTextField ( )) - CHECK_NULL_PTR_ERROR (_edgePanel->getNameTextField ( )) - _facePanel->getNameTextField ( - )->setLinkedSeizureManagers (0, _edgePanel->getNameTextField ( )); - _edgePanel->getNameTextField ( - )->setLinkedSeizureManagers (_facePanel->getNameTextField ( ), 0); - - cutDefinitionModifiedCallback ( ); -} // QtTopologySplitFacePanel::QtTopologySplitFacePanel - - -QtTopologySplitFacePanel::QtTopologySplitFacePanel ( - const QtTopologySplitFacePanel& cao) - : QtMgx3DOperationPanel ( - 0, *new QtMgx3DMainWindow (0), 0, "", ""), - _facePanel (0), _edgePanel (0), _cutDefinitionButtonGroup (0), - _ratioTextField (0), _cutPointEntityPanel (0), - _projectVerticesCheckBox (0) -{ - MGX_FORBIDDEN ("QtTopologySplitFacePanel copy constructor is not allowed."); -} // QtTopologySplitFacePanel::QtTopologySplitFacePanel (const QtTopologySplitFacePanel&) - - -QtTopologySplitFacePanel& QtTopologySplitFacePanel::operator = ( - const QtTopologySplitFacePanel&) -{ - MGX_FORBIDDEN ("QtTopologySplitFacePanel assignment operator is not allowed."); - return *this; -} // QtTopologySplitFacePanel::QtTopologySplitFacePanel (const QtTopologySplitFacePanel&) - - -QtTopologySplitFacePanel::~QtTopologySplitFacePanel ( ) -{ -} // QtTopologySplitFacePanel::~QtTopologySplitFacePanel - - -void QtTopologySplitFacePanel::reset ( ) -{ - BEGIN_QT_TRY_CATCH_BLOCK - - CHECK_NULL_PTR_ERROR (_facePanel) - CHECK_NULL_PTR_ERROR (_edgePanel) - CHECK_NULL_PTR_ERROR (_ratioTextField) - CHECK_NULL_PTR_ERROR (_cutPointEntityPanel) - _facePanel->reset ( ); - _edgePanel->reset ( ); - _ratioTextField->setValue (0.5); - _cutPointEntityPanel->reset ( ); - - COMPLETE_QT_TRY_CATCH_BLOCK (true, this, "Magix 3D") - - QtMgx3DOperationPanel::reset ( ); -} // QtTopologySplitFacePanel::reset - - -void QtTopologySplitFacePanel::cancel ( ) -{ - QtMgx3DOperationPanel::cancel ( ); - - CHECK_NULL_PTR_ERROR (_facePanel) - CHECK_NULL_PTR_ERROR (_edgePanel) - CHECK_NULL_PTR_ERROR (_cutPointEntityPanel) - _facePanel->stopSelection ( ); - _edgePanel->stopSelection ( ); - _cutPointEntityPanel->stopSelection ( ); - - if (true == cancelClearEntities ( )) - { - BEGIN_QT_TRY_CATCH_BLOCK - - _facePanel->setUniqueName (""); - _edgePanel->setUniqueName (""); - _cutPointEntityPanel->setUniqueName (""); - - COMPLETE_QT_TRY_CATCH_BLOCK (true, this, "Magix 3D") - } // if (true == cancelClearEntities ( )) -} // QtTopologySplitFacePanel::cancel - - -void QtTopologySplitFacePanel::autoUpdate ( ) -{ - CHECK_NULL_PTR_ERROR (_facePanel) - CHECK_NULL_PTR_ERROR (_edgePanel) - CHECK_NULL_PTR_ERROR (_cutPointEntityPanel) - -#ifdef AUTO_UPDATE_OLD_SCHEME - if (true == autoUpdateUsesSelection ( )) - { - const vector selectedFaces = - getSelectionManager ( ).getEntitiesNames (FilterEntity::TopoCoFace); - if (1 == selectedFaces.size ( )) - _facePanel->setUniqueName (selectedFaces [0]); - const vector selectedEdges = - getSelectionManager ( ).getEntitiesNames (FilterEntity::TopoCoEdge); - if (1 == selectedEdges.size ( )) - _edgePanel->setUniqueName (selectedEdges [0]); - } // if (true == autoUpdateUsesSelection ( )) -#else // AUTO_UPDATE_OLD_SCHEME - _facePanel->setUniqueName (""); - _edgePanel->setUniqueName (""); - _cutPointEntityPanel->clearSelection ( ); -#endif // AUTO_UPDATE_OLD_SCHEME - - _facePanel->actualizeGui (true); - _edgePanel->actualizeGui (true); - _cutPointEntityPanel->actualizeGui (true); - - QtMgx3DOperationPanel::autoUpdate ( ); -} // QtTopologySplitFacePanel::autoUpdate - - -string QtTopologySplitFacePanel::getFaceName ( ) const -{ - CHECK_NULL_PTR_ERROR (_facePanel) - return _facePanel->getUniqueName ( ); -} // QtTopologySplitFacePanel::getFaceName - - -string QtTopologySplitFacePanel::getEdgeName ( ) const -{ - CHECK_NULL_PTR_ERROR (_edgePanel) - return _edgePanel->getUniqueName ( ); -} // QtTopologySplitFacePanel::getEdgeName - - -QtTopologySplitFacePanel::CUT_DEFINITION_METHOD - QtTopologySplitFacePanel::getCutDefinitionMethod ( ) const -{ - CHECK_NULL_PTR_ERROR (_cutDefinitionButtonGroup) - return (QtTopologySplitFacePanel::CUT_DEFINITION_METHOD)_cutDefinitionButtonGroup->checkedId ( ); -} // QtTopologySplitFacePanel::getCutDefinitionMethod - - -double QtTopologySplitFacePanel::getRatio ( ) const -{ - CHECK_NULL_PTR_ERROR (_ratioTextField) - return _ratioTextField->getValue ( ); -} // QtTopologySplitFacePanel::getRatio - - -Math::Point QtTopologySplitFacePanel::getCutPoint ( ) const -{ - CHECK_NULL_PTR_ERROR (_cutPointEntityPanel) - const string name = _cutPointEntityPanel->getUniqueName ( ); - if (0 == name.length ( )) - return Math::Point ( ); - - Entity* entity = &getContext().nameToEntity (name); - GeomEntity* ge = dynamic_cast(entity); - Topo::Vertex* v = dynamic_cast(entity); - - if (0 != ge) - return ge->getCenteredPosition ( ); - else if (0 != v) - return v->getCoord ( ); - - throw Exception (UTF8String ("Définition de la position de découpe : absence d'entité sélectionnée.", Charset::UTF_8)); -} // QtTopologySplitFacePanel::getCutPoint - - -bool QtTopologySplitFacePanel::projectCreatedVertices ( ) const -{ - CHECK_NULL_PTR_ERROR (_projectVerticesCheckBox) - return Qt::Checked == _projectVerticesCheckBox->checkState ( ) ? - true : false; -} // QtTopologySplitFacePanel::projectCreatedVertices - - -void QtTopologySplitFacePanel::preview (bool show, bool destroyInteractor) -{ - // Lors de la construction getGraphicalWidget peut être nul ... - try - { - getRenderingManager ( ); - } - catch (...) - { - return; - } - - QtMgx3DOperationPanel::preview (show, destroyInteractor); - if ((false == show) || (false == previewResult ( ))) - return; - - try - { - - Context* context = dynamic_cast(&getContext ( )); - CHECK_NULL_PTR_ERROR (context) - const string faceName = getFaceName ( ); - const string edgeName = getEdgeName ( ); - const bool projectVertices = projectCreatedVertices ( ); - CoFace* face = - getContext ( ).getTopoManager ( ).getCoFace (faceName, true); - CoEdge* edge = - getContext ( ).getTopoManager ( ).getCoEdge (edgeName, true); - std::unique_ptr command; - switch (getCutDefinitionMethod ( )) - { - case QtTopologySplitFacePanel::CDM_RATIO : - command.reset (new CommandSplitFaces ( - *context, face, edge, getRatio ( ), projectVertices)); - break; - case QtTopologySplitFacePanel::CDM_POINT : - command.reset (new CommandSplitFaces ( - *context, face, edge, getCutPoint ( ), projectVertices)); - break; - default : - throw Exception (UTF8String ("QtTopologySplitFacePanel::preview : cas non implémenté.", Charset::UTF_8)); - } // switch (getCutDefinitionMethod ( )) - TopoDisplayRepresentation dr (DisplayRepresentation::WIRE); - command->getPreviewRepresentation (dr); - const vector& points = dr.getPoints ( ); - const vector& indices = dr.getCurveDiscretization ( ); - - DisplayProperties graphicalProps; - graphicalProps.setWireColor (Color ( - 255 * Resources::instance ( )._previewColor.getRed ( ), - 255 * Resources::instance ( )._previewColor.getGreen ( ), - 255 * Resources::instance ( )._previewColor.getBlue ( ))); - graphicalProps.setLineWidth ( - Resources::instance ( )._previewWidth.getValue ( )); - RenderingManager::RepresentationID repID = - getRenderingManager ( ).createSegmentsWireRepresentation ( - points, indices, graphicalProps, true); - registerPreviewedObject (repID); - - getRenderingManager ( ).forceRender ( ); - - } - catch (...) - { - } -} // QtTopologySplitFacePanel::preview - - -vector QtTopologySplitFacePanel::getInvolvedEntities ( ) -{ - CHECK_NULL_PTR_ERROR (_cutPointEntityPanel) - - vector entities; - const string faceName = getFaceName ( ); - const string edgeName = getEdgeName ( ); - CoFace* face = - getContext ( ).getTopoManager ( ).getCoFace (faceName, false); - if (0 != face) - entities.push_back (face); - TopoEntity* edge = - getContext ( ).getTopoManager ( ).getCoEdge (edgeName, false); - if (0 != edge) - entities.push_back (edge); - - switch (getCutDefinitionMethod ( )) - { - case QtTopologySplitFacePanel::CDM_POINT : - { - CHECK_NULL_PTR_ERROR (_cutPointEntityPanel) - const string point = _cutPointEntityPanel->getUniqueName ( ); - if (0 != point.length ( )) - entities.push_back (&getContext().nameToEntity (point)); - } - break; - } // switch (getCutDefinitionMethod ( )) - - return entities; -} // QtTopologySplitFacePanel::getInvolvedEntities - - -void QtTopologySplitFacePanel::operationCompleted ( ) -{ - highlight (false); // car champs de texte modifiés - - BEGIN_QT_TRY_CATCH_BLOCK - - if (0 != _facePanel) - { - _facePanel->stopSelection ( ); - _facePanel->setUniqueName ("" ); - } - if (0 != _edgePanel) - { - _edgePanel->stopSelection ( ); - _edgePanel->setUniqueName (""); - } - if (0 != _cutPointEntityPanel) - { - _cutPointEntityPanel->stopSelection ( ); - _cutPointEntityPanel->setUniqueName (""); - } - - COMPLETE_QT_TRY_CATCH_BLOCK (true, this, "Magix 3D") - - QtMgx3DOperationPanel::operationCompleted ( ); -} // QtTopologySplitFacePanel::operationCompleted - - -void QtTopologySplitFacePanel::cutDefinitionModifiedCallback ( ) -{ - BEGIN_QT_TRY_CATCH_BLOCK - - CHECK_NULL_PTR_ERROR (_ratioTextField) - CHECK_NULL_PTR_ERROR (_cutPointEntityPanel) - - switch (getCutDefinitionMethod ( )) - { - case QtTopologySplitFacePanel::CDM_RATIO : - _ratioTextField->setEnabled (true); - _cutPointEntityPanel->setEnabled (false); - break; - case QtTopologySplitFacePanel::CDM_POINT : - _ratioTextField->setEnabled (false); - _cutPointEntityPanel->setEnabled (true); - break; - } // switch (getCutDefinitionMethod ( )) - - COMPLETE_QT_TRY_CATCH_BLOCK (true, this, "Magix 3D") -} // QtTopologySplitFacePanel::cutDefinitionModifiedCallback - - -// =========================================================================== -// LA CLASSE QtTopologySplitFaceAction -// =========================================================================== - -QtTopologySplitFaceAction::QtTopologySplitFaceAction ( - const QIcon& icon, const QString& text, - QtMgx3DMainWindow& mainWindow, const QString& tooltip) - : QtMgx3DTopoOperationAction (icon, text, mainWindow, tooltip) -{ - QtTopologySplitFacePanel* operationPanel = - new QtTopologySplitFacePanel (&getOperationPanelParent ( ), - text.toStdString ( ), mainWindow, this); - setOperationPanel (operationPanel); -} // QtTopologySplitFaceAction::QtTopologySplitFaceAction - - -QtTopologySplitFaceAction::QtTopologySplitFaceAction ( - const QtTopologySplitFaceAction&) - : QtMgx3DTopoOperationAction ( - QIcon (""), "", *new QtMgx3DMainWindow (0), "") -{ - MGX_FORBIDDEN ("QtTopologySplitFaceAction copy constructor is not allowed.") -} // QtTopologySplitFaceAction::QtTopologySplitFaceAction - - -QtTopologySplitFaceAction& QtTopologySplitFaceAction::operator = ( - const QtTopologySplitFaceAction&) -{ - MGX_FORBIDDEN ("QtTopologySplitFaceAction assignment operator is not allowed.") - return *this; -} // QtTopologySplitFaceAction::operator = - - -QtTopologySplitFaceAction::~QtTopologySplitFaceAction ( ) -{ -} // QtTopologySplitFaceAction::~QtTopologySplitFaceAction - - -QtTopologySplitFacePanel* - QtTopologySplitFaceAction::getTopologySplitFacePanel ( ) -{ - return dynamic_cast(getOperationPanel ( )); -} // QtTopologySplitFaceAction::getTopologySplitFacePanel - - -void QtTopologySplitFaceAction::executeOperation ( ) -{ - QtTopologySplitFacePanel* panel = dynamic_cast(getTopologySplitFacePanel ( )); - CHECK_NULL_PTR_ERROR (panel) - - // Validation paramétrage : - QtMgx3DOperationAction::executeOperation ( ); - - // Récupération des paramètres de découpage de la face topologique : - const string faceName = panel->getFaceName ( ); - const string edgeName = panel->getEdgeName ( ); - const bool projectVertices = panel->projectCreatedVertices ( ); - - Mgx3D::Internal::M3DCommandResult* result = 0; - switch (panel->getCutDefinitionMethod ( )) - { - case QtTopologySplitFacePanel::CDM_RATIO : - result = getContext ( ).getTopoManager ( ).splitFace ( - faceName, edgeName, panel->getRatio ( ), projectVertices); - break; - case QtTopologySplitFacePanel::CDM_POINT : - result = getContext ( ).getTopoManager ( ).splitFace ( - faceName, edgeName, panel->getCutPoint ( ), projectVertices); - break; - default : - { - UTF8String message (Charset::UTF_8); - message << "Position de découpe non supportée (" - << (unsigned long)panel->getCutDefinitionMethod ( ) << ")."; - INTERNAL_ERROR (exc, message, "QtTopologySplitFaceAction::executeOperation") - throw exc; - } - } // switch (panel->getCutDefinitionMethod ( )) - CHECK_NULL_PTR_ERROR (result) - setCommandResult (result); - if (Command::FAIL == result->getStatus ( )) - throw Exception (result->getErrorMessage ( )); - else if (Command::CANCELED == result->getStatus ( )) - throw Exception ("Opération annulée"); -} // QtTopologySplitFaceAction::executeOperation - - -// ============================================================================ -// FONCTIONS STATIQUES -// ============================================================================ - - - -} // namespace QtComponents - -} // namespace Mgx3D diff --git a/src/QtComponents/QtTopologySplitFacesAction.cpp b/src/QtComponents/QtTopologySplitFacesAction.cpp index a37c2672..69cc4db3 100644 --- a/src/QtComponents/QtTopologySplitFacesAction.cpp +++ b/src/QtComponents/QtTopologySplitFacesAction.cpp @@ -52,7 +52,7 @@ QtTopologySplitFacesPanel::QtTopologySplitFacesPanel ( QtMgx3DApplication::HelpSystem::instance ( ).splitFacesOperationTag), _facesPanel (0), _cutDefinitionButtonGroup (0), _edgePanel (0), _ratioTextField (0), _cutPointEntityPanel (0), _oGridRatioTextField (0), - _allFacesCheckBox (0) + _projectVerticesCheckBox (0), _allFacesCheckBox (0) { QVBoxLayout* layout = new QVBoxLayout (this); setLayout (layout); @@ -157,6 +157,14 @@ QtTopologySplitFacesPanel::QtTopologySplitFacesPanel ( connect (_oGridRatioTextField, SIGNAL (textEdited (const QString&)), this, SLOT (parametersModifiedCallback ( ))); + // Faut il projeter les sommets créés sur la discrétisation initiale ? + _projectVerticesCheckBox = new QCheckBox ( + "Projeter les sommets créés sur la discrétisation initiale", this); + _projectVerticesCheckBox->setChecked (true); + layout->addWidget (_projectVerticesCheckBox); + connect (_projectVerticesCheckBox, SIGNAL (stateChanged (int)), this, + SLOT (parametersModifiedCallback ( ))); + addPreviewCheckBox (false); layout->addStretch (2); @@ -179,7 +187,7 @@ QtTopologySplitFacesPanel::QtTopologySplitFacesPanel ( 0, *new QtMgx3DMainWindow (0), 0, "", ""), _facesPanel (0), _cutDefinitionButtonGroup (0), _edgePanel (0), _ratioTextField (0), _cutPointEntityPanel (0), - _oGridRatioTextField (0), _allFacesCheckBox (0) + _oGridRatioTextField (0), _projectVerticesCheckBox (0), _allFacesCheckBox (0) { MGX_FORBIDDEN ("QtTopologySplitFacesPanel copy constructor is not allowed."); } // QtTopologySplitFacesPanel::QtTopologySplitFacesPanel (const QtTopologySplitFacesPanel&) @@ -354,6 +362,12 @@ double QtTopologySplitFacesPanel::getOGridRatio ( ) const return _oGridRatioTextField->getValue ( ); } // QtTopologySplitFacesPanel::getOGridRatio +bool QtTopologySplitFacesPanel::projectCreatedVertices ( ) const +{ + CHECK_NULL_PTR_ERROR (_projectVerticesCheckBox) + return Qt::Checked == _projectVerticesCheckBox->checkState ( ) ? + true : false; +} // QtTopologySplitFacePanel::projectCreatedVertices void QtTopologySplitFacesPanel::preview (bool show, bool destroyInteractor) { @@ -381,6 +395,7 @@ void QtTopologySplitFacesPanel::preview (bool show, bool destroyInteractor) const double oGridRatio = getOGridRatio ( ); CoEdge* edge = getContext ( ).getTopoManager ( ).getCoEdge (edgeName, true); + const bool projectVertices = projectCreatedVertices ( ); if (true == allFaces ( )) { @@ -389,12 +404,12 @@ void QtTopologySplitFacesPanel::preview (bool show, bool destroyInteractor) case QtTopologySplitFacesPanel::CDM_RATIO : command.reset ( new CommandSplitFaces ( - *context, edge, getRatio ( ), oGridRatio)); + *context, edge, getRatio ( ), oGridRatio, projectVertices)); break; case QtTopologySplitFacesPanel::CDM_POINT : command.reset ( new CommandSplitFaces ( - *context, edge, getCutPoint ( ), oGridRatio)); + *context, edge, getCutPoint ( ), oGridRatio, projectVertices)); break; default : throw Exception (UTF8String ("QtTopologySplitFacesPanel::preview : cas non implémenté.", Charset::UTF_8)); @@ -622,16 +637,19 @@ void QtTopologySplitFacesAction::executeOperation ( ) // Récupération des paramètres de découpage des faces topologiques : const string edgeName = panel->getEdgeName ( ); const double oGridRatio = panel->getOGridRatio ( ); + const bool projectVertices = panel->projectCreatedVertices ( ); if (true == panel->allFaces ( )) { switch (panel->getCutDefinitionMethod ( )) { case QtTopologySplitFacesPanel::CDM_RATIO : - cmdResult = getContext ( ).getTopoManager ( ).splitAllFaces (edgeName, panel->getRatio ( ), oGridRatio); + cmdResult = getContext ( ).getTopoManager ( ).splitAllFaces ( + edgeName, panel->getRatio ( ), oGridRatio, projectVertices); break; case QtTopologySplitFacesPanel::CDM_POINT : - cmdResult = getContext ( ).getTopoManager ( ).splitAllFaces (edgeName, panel->getCutPoint ( ), oGridRatio); + cmdResult = getContext ( ).getTopoManager ( ).splitAllFaces ( + edgeName, panel->getCutPoint ( ), oGridRatio, projectVertices); break; default : { @@ -650,10 +668,10 @@ void QtTopologySplitFacesAction::executeOperation ( ) switch (panel->getCutDefinitionMethod ( )) { case QtTopologySplitFacesPanel::CDM_RATIO : - cmdResult = getContext ( ).getTopoManager ( ).splitFaces (facesNames, edgeName, panel->getRatio ( ), oGridRatio); + cmdResult = getContext ( ).getTopoManager ( ).splitFaces (facesNames, edgeName, panel->getRatio ( ), oGridRatio, projectVertices); break; case QtTopologySplitFacesPanel::CDM_POINT : - cmdResult = getContext ( ).getTopoManager ( ).splitFaces (facesNames, edgeName, panel->getCutPoint ( ), oGridRatio); + cmdResult = getContext ( ).getTopoManager ( ).splitFaces (facesNames, edgeName, panel->getCutPoint ( ), oGridRatio, projectVertices); break; default : { diff --git a/src/QtComponents/RenderingManager.cpp b/src/QtComponents/RenderingManager.cpp index a8ad084c..82bc14e7 100644 --- a/src/QtComponents/RenderingManager.cpp +++ b/src/QtComponents/RenderingManager.cpp @@ -957,16 +957,17 @@ void RenderingManager::updateRepresentation (Mgx3D::Utils::Entity& entity) void RenderingManager::updateRepresentations ( ) { vector entities = getDisplayedEntities ( ); - for (vector::iterator it = entities.begin ( ); - entities.end ( ) !=it; it++) + size_t count = 1; + for (vector::iterator it = entities.begin ( ); entities.end ( ) !=it; it++, count++) { - DisplayProperties::GraphicalRepresentation* rep = - (*it)->getDisplayProperties ( ).getGraphicalRepresentation ( ); + DisplayProperties::GraphicalRepresentation* rep = (*it)->getDisplayProperties ( ).getGraphicalRepresentation ( ); if (0 != rep) { unsigned long mask = rep->getRepresentationMask ( ); rep->updateRepresentation (mask, true); } + if (0 == count % Resources::instance ( )._updateRefreshRate.getValue ( )) + forceRender ( ); } // for (vector::iterator it = entities.begin ( ); ... } // RenderingManager::updateRepresentations diff --git a/src/QtComponents/protected/QtComponents/QtTopologySplitFaceAction.h b/src/QtComponents/protected/QtComponents/QtTopologySplitFaceAction.h deleted file mode 100644 index adb64b64..00000000 --- a/src/QtComponents/protected/QtComponents/QtTopologySplitFaceAction.h +++ /dev/null @@ -1,229 +0,0 @@ -/** - * \file QtTopologySplitFaceAction.h - * \author Charles PIGNEROL - * \date 17/03/2014 - */ -#ifndef QT_TOPOLOGY_SPLIT_FACE_ACTION_H -#define QT_TOPOLOGY_SPLIT_FACE_ACTION_H - -#include "Internal/Context.h" - -#include "QtComponents/QtMgx3DEntityPanel.h" -#include "QtComponents/QtMgx3DOperationsPanel.h" -#include "QtComponents/QtMgx3DTopoOperationAction.h" - -#include - -#include -#include - - -namespace Mgx3D -{ - -namespace QtComponents -{ - -/** - * Panneau d'édition des paramètres de découpe d'une face topologique. - */ -class QtTopologySplitFacePanel : public QtMgx3DOperationPanel -{ - Q_OBJECT - - public : - - /** - * Le positionnement de la coupe. - */ - enum CUT_DEFINITION_METHOD { CDM_RATIO, CDM_POINT }; - - /** - * Créé l'ihm. - * \param Widget parent. - * \param Nom du panneau - * \param Fenêtre principale Magix 3D de rattachement, utilisée - * notamment pour récupérer le contexte. - * \param Eventuelle action associée à ce panneau. - */ - QtTopologySplitFacePanel ( - QWidget* parent, const std::string& panelName, - Mgx3D::QtComponents::QtMgx3DMainWindow& mainWindow, - Mgx3D::QtComponents::QtMgx3DOperationAction* action); - - /** - * Destructeur. RAS. - */ - virtual ~QtTopologySplitFacePanel ( ); - - /** - * Réinitialise le panneau. - */ - virtual void reset ( ); - - /** - * Méthode appelée lorsque l'utilisateur suspend l'édition de l'opération. - * Restitue l'environnement dans son état initial. - * Invoque preview (false). - * \see preview - */ - virtual void cancel ( ); - - /** - * Actualise le panneau en fonction du contexte. - * Invoque preview (true, true). - * \see preview - */ - virtual void autoUpdate ( ); - - /** - * \return Les nom de la face à découper. - * \see getEdgeName - */ - virtual std::string getFaceName ( ) const; - - /** - * \return Le nom de l'arête orthogonale au plan de coupe. - * \see getFaceName - */ - virtual std::string getEdgeName ( ) const; - - /** - * \return La méthode de définition de la coupe. - */ - virtual CUT_DEFINITION_METHOD getCutDefinitionMethod ( ) const; - - /** - * \return Le ratio de découpage de l'arête au niveau du plan de coupe - * orthogonal à l'arête. - */ - virtual double getRatio ( ) const; - - /** - * \return Le point de découpe. - */ - virtual Mgx3D::Utils::Math::Point getCutPoint ( ) const; - - /** - * \return true s'il faut projeter les sommets créés sur la - * discrétisation initiale, false dans le cas contraire. - */ - virtual bool projectCreatedVertices ( ) const; - - /** - * \param true pour prévisualiser les entités concernées par - * le découpage, false pour arrêter la prévisualisation. - * \param true s'il faut détruire l'éventuel interacteur dans - * le cas d'un arrêt de la prévisualisation. - */ - virtual void preview (bool show, bool destroyInteractor); - - - protected : - - /** - * \return La liste des entités impliquées dans l'opération. - */ - virtual std::vector getInvolvedEntities ( ); - - /** - * Invoqué lorsque l'opération a été exécutée. Actualise le panneau. - * cf. spécifications dans la classe de base. - */ - virtual void operationCompleted ( ); - - - protected slots : - - /** - * Appelé lorsque l'utilisateur change de méthode de définition de la - * découpe. Actualise l'IHM. - */ - virtual void cutDefinitionModifiedCallback ( ); - - - private : - - /** - * Constructeur de copie et opérateur = opérations interdites. - */ - QtTopologySplitFacePanel (const QtTopologySplitFacePanel&); - QtTopologySplitFacePanel& operator = (const QtTopologySplitFacePanel&); - - /** La face à découper. */ - QtMgx3DEntityPanel* _facePanel; - - /** La définition de la position de la découpe. */ - QButtonGroup* _cutDefinitionButtonGroup; - - /** L'arête orthogonale au plan de coupe. */ - QtMgx3DEntityPanel* _edgePanel; - - /** Le ratio de découpage de l'arête. */ - QtDoubleTextField* _ratioTextField; - - /** L'entité de définition du positionnement de la coupe. */ - QtMgx3DEntityPanel* _cutPointEntityPanel; - - /** Faut-il projeter les sommets créés sur la discrétisation initiale ? */ - QCheckBox* _projectVerticesCheckBox; -}; // class QtTopologySplitFacePanel - - -/** - * Classe d'action type check box associée à un panneau type - * QtTopologySplitFacePanel de découpe d'une face topologique. - */ -class QtTopologySplitFaceAction : public QtMgx3DTopoOperationAction -{ - public : - - /** - * Créé et s'associe une instance de la classe - * QtTopologySplitFacePanel. - * \param Icône représentant l'action. - * \param Texte représentant l'action. - * \param Fenêtre principale Magix 3D de rattachement, utilisée - * notamment pour récupérer le contexte et le panneau contenant - * les icônes. - * \param Tooltip décrivant l'action. - */ - QtTopologySplitFaceAction ( - const QIcon& icon, const QString& text, - Mgx3D::QtComponents::QtMgx3DMainWindow& mainWindow, - const QString& tooltip); - - /** - * Destructeur. RAS. - */ - virtual ~QtTopologySplitFaceAction ( ); - - /** - * \return Le panneau de paramétrage de la découpe. - */ - virtual QtTopologySplitFacePanel* getTopologySplitFacePanel ( ); - - /** - * Découpe la face topologique conformément au paramétrage de - * son panneau associé. Invoque préalablement - * QtMgx3DTopoOperationAction::executeOperation. - */ - virtual void executeOperation ( ); - - - private : - - /** - * Constructeur de copie et opérateur = : interdits. - */ - QtTopologySplitFaceAction (const QtTopologySplitFaceAction&); - QtTopologySplitFaceAction& operator = (const QtTopologySplitFaceAction&); -}; // class QtTopologyCreationAction - - - -} // namespace QtComponents - -} // namespace Mgx3D - -#endif // QT_TOPOLOGY_SPLIT_FACE_ACTION_H diff --git a/src/QtComponents/protected/QtComponents/QtTopologySplitFacesAction.h b/src/QtComponents/protected/QtComponents/QtTopologySplitFacesAction.h index ac47e6f8..a6e977d9 100644 --- a/src/QtComponents/protected/QtComponents/QtTopologySplitFacesAction.h +++ b/src/QtComponents/protected/QtComponents/QtTopologySplitFacesAction.h @@ -118,6 +118,12 @@ class QtTopologySplitFacesPanel : public QtMgx3DOperationPanel */ virtual double getOGridRatio ( ) const; + /** + * \return true s'il faut projeter les sommets créés sur la + * discrétisation initiale, false dans le cas contraire. + */ + virtual bool projectCreatedVertices ( ) const; + /** * \param true pour prévisualiser les entités concernées par * le découpage, false pour arrêter la prévisualisation. @@ -183,6 +189,9 @@ class QtTopologySplitFacesPanel : public QtMgx3DOperationPanel /** Le ratio de découpage de l'o-grid. */ QtDoubleTextField* _oGridRatioTextField; + /** Faut-il projeter les sommets créés sur la discrétisation initiale ? */ + QCheckBox* _projectVerticesCheckBox; + /** La case à cocher "Toutes les faces ?". */ QCheckBox* _allFacesCheckBox; }; // class QtTopologySplitFacesPanel diff --git a/src/Utils/SerializedRepresentation.cpp b/src/Utils/SerializedRepresentation.cpp index 178de3a2..73c9ef6c 100644 --- a/src/Utils/SerializedRepresentation.cpp +++ b/src/Utils/SerializedRepresentation.cpp @@ -525,7 +525,7 @@ string SerializedRepresentation::toString ( ) const << "\t" << (*itps)->toString( ); } - return description.iso ( ); + return description; } // SerializedRepresentation::toString diff --git a/test_link/test_description.py b/test_link/test_description.py new file mode 100644 index 00000000..2d9799f7 --- /dev/null +++ b/test_link/test_description.py @@ -0,0 +1,59 @@ +import pyMagix3D as Mgx3D +import os +import re + +def test_geom_description(): + ctx = Mgx3D.getStdContext() + ctx.clearSession() # Clean the session after the previous test + gm = ctx.getGeomManager() + + gm.newBox (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), "") + compare(gm.getTextualDescription("Pt0000", 0), "test_description_pt0000.txt") + compare(gm.getTextualDescription("Crb0000", 1), "test_description_crb0000.txt") + compare(gm.getTextualDescription("Surf0000", 2), "test_description_surf0000.txt") + compare(gm.getTextualDescription("Vol0000", 3), "test_description_vol0000.txt") + +# Filtrage du bloc propriétés OCC qui n'est présent qu'en mode DEBUG +def load_and_filter(filename): + with open(filename, encoding="utf-8") as f: + lines = f.readlines() + + result = [] + skip_block = False + skip_words = ["Précision", "Param first", "Param last", "Nb noeuds", "Nb poles"] + for line in lines: + # Début du bloc à ignorer + if "SerializedRepresentation Propriétés OCC" in line: + skip_block = True + continue + if skip_block: + # fin du bloc : quand on a sauté "Properties sets", on arrête d’ignorer + # (on avait laissé le "Properties sets" précédent le bloc) + if "Properties sets" in line: + skip_block = False + continue + + # Mots qui ne sont qu'en mode DEBUG + if not any(w in line for w in skip_words): + result.append(line) + + return result + +def compare(text, model_file_name): + test_folder = os.path.dirname(__file__) + + # Ecriture d'un fichier avec le texte pour avoir le même formatage + file_path = os.path.join(test_folder, model_file_name + ".tmp") + with open(file_path, "w", encoding="utf-8") as f: + f.write(text) + + # Lecture du fichier qui vient d'être écrit + text = load_and_filter(file_path) + os.remove(file_path) + + # Lecture du fichier modèle + file_path = os.path.join(test_folder, model_file_name) + model = load_and_filter(file_path) + + # Comparaison en ignorant le hashcode + assert text == model diff --git a/test_link/test_description_crb0000.txt b/test_link/test_description_crb0000.txt new file mode 100644 index 00000000..89986011 --- /dev/null +++ b/test_link/test_description_crb0000.txt @@ -0,0 +1,77 @@ +SerializedRepresentation Description +Path : Description +Properties : + Relations topologiques : Aucune +Properties sets : + SerializedRepresentation Propriétés génériques +Path : Description.Propriétés génériques +Properties : + Nom unique : GeomCurve_Crb0000 + Identifiant unique : 8 + Type : GeomCurve + Dimension : 1 + Est détruit : false + Est visible : false +Properties sets : + SerializedRepresentation Boite englobante +Path : Description.Propriétés génériques.Boite englobante +Properties : + X min : -1e-7 + X max : 1e-7 + Y min : -1e-7 + Y max : 1e-7 + Z min : -1e-7 + Z max : 1.0000001 +Properties sets : + SerializedRepresentation Relations géométriques +Path : Description.Relations géométriques +Properties : +Properties sets : + SerializedRepresentation Sommets +Path : Description.Relations géométriques.Sommets +Properties : + Pt0000 : GeomVertex + Pt0001 : GeomVertex +Properties sets : + SerializedRepresentation Courbes +Path : Description.Relations géométriques.Courbes +Properties : + Crb0001 : GeomCurve + Crb0003 : GeomCurve + Crb0008 : GeomCurve + Crb0009 : GeomCurve +Properties sets : + SerializedRepresentation Surfaces +Path : Description.Relations géométriques.Surfaces +Properties : + Surf0000 : GeomSurface + Surf0002 : GeomSurface +Properties sets : + SerializedRepresentation Volumes +Path : Description.Relations géométriques.Volumes +Properties : + Vol0000 : GeomVolume +Properties sets : + SerializedRepresentation Relations vers des groupes +Path : Description.Relations vers des groupes +Properties : +Properties sets : + SerializedRepresentation Groupes 1D +Path : Description.Relations vers des groupes.Groupes 1D +Properties : + Hors_Groupe_1D : Group1D +Properties sets : + SerializedRepresentation Propriétés OCC +Path : Description.Propriétés OCC +Properties : + HashCode : 698035809 +Properties sets : + SerializedRepresentation Propriétés géométriques +Path : Description.Propriétés géométriques +Properties : + Longueur : 1.000000e+00 + Précision : 1.000000e-07 + Type : segment + Param first : 0.000000e+00 + Param last : 1.000000e+00 +Properties sets : \ No newline at end of file diff --git a/test_link/test_description_pt0000.txt b/test_link/test_description_pt0000.txt new file mode 100644 index 00000000..6c735e89 --- /dev/null +++ b/test_link/test_description_pt0000.txt @@ -0,0 +1,75 @@ +SerializedRepresentation Description +Path : Description +Properties : + Relations topologiques : Aucune +Properties sets : + SerializedRepresentation Propriétés génériques +Path : Description.Propriétés génériques +Properties : + Nom unique : GeomVertex_Pt0000 + Identifiant unique : 20 + Type : GeomVertex + Dimension : 0 + Est détruit : false + Est visible : false +Properties sets : + SerializedRepresentation Boite englobante +Path : Description.Propriétés génériques.Boite englobante +Properties : + X min : -1e-7 + X max : 1e-7 + Y min : -1e-7 + Y max : 1e-7 + Z min : 9.999999e-1 + Z max : 1.0000001 +Properties sets : + SerializedRepresentation Relations géométriques +Path : Description.Relations géométriques +Properties : +Properties sets : + SerializedRepresentation Sommets +Path : Description.Relations géométriques.Sommets +Properties : + Pt0001 : GeomVertex + Pt0002 : GeomVertex + Pt0004 : GeomVertex +Properties sets : + SerializedRepresentation Courbes +Path : Description.Relations géométriques.Courbes +Properties : + Crb0000 : GeomCurve + Crb0001 : GeomCurve + Crb0009 : GeomCurve +Properties sets : + SerializedRepresentation Surfaces +Path : Description.Relations géométriques.Surfaces +Properties : + Surf0000 : GeomSurface + Surf0002 : GeomSurface + Surf0005 : GeomSurface +Properties sets : + SerializedRepresentation Volumes +Path : Description.Relations géométriques.Volumes +Properties : + Vol0000 : GeomVolume +Properties sets : + SerializedRepresentation Relations vers des groupes +Path : Description.Relations vers des groupes +Properties : +Properties sets : + SerializedRepresentation Groupes 0D +Path : Description.Relations vers des groupes.Groupes 0D +Properties : + Hors_Groupe_0D : Group0D +Properties sets : + SerializedRepresentation Propriétés OCC +Path : Description.Propriétés OCC +Properties : + HashCode : 610304081 +Properties sets : + SerializedRepresentation Propriété géométrique +Path : Description.Propriété géométrique +Properties : + Coordonnées : (0, 0, 1) + Précision : 1.000000e-07 +Properties sets : \ No newline at end of file diff --git a/test_link/test_description_surf0000.txt b/test_link/test_description_surf0000.txt new file mode 100644 index 00000000..810e6b2f --- /dev/null +++ b/test_link/test_description_surf0000.txt @@ -0,0 +1,79 @@ +SerializedRepresentation Description +Path : Description +Properties : + Relations topologiques : Aucune +Properties sets : + SerializedRepresentation Propriétés génériques +Path : Description.Propriétés génériques +Properties : + Nom unique : GeomSurface_Surf0000 + Identifiant unique : 2 + Type : GeomSurface + Dimension : 2 + Est détruit : false + Est visible : false +Properties sets : + SerializedRepresentation Boite englobante +Path : Description.Propriétés génériques.Boite englobante +Properties : + X min : -1e-7 + X max : 1e-7 + Y min : -1e-7 + Y max : 1.0000001 + Z min : -1e-7 + Z max : 1.0000001 +Properties sets : + SerializedRepresentation Relations géométriques +Path : Description.Relations géométriques +Properties : +Properties sets : + SerializedRepresentation Sommets +Path : Description.Relations géométriques.Sommets +Properties : + Pt0000 : GeomVertex + Pt0001 : GeomVertex + Pt0002 : GeomVertex + Pt0003 : GeomVertex +Properties sets : + SerializedRepresentation Courbes +Path : Description.Relations géométriques.Courbes +Properties : + Crb0000 : GeomCurve + Crb0001 : GeomCurve + Crb0002 : GeomCurve + Crb0003 : GeomCurve +Properties sets : + SerializedRepresentation Surfaces +Path : Description.Relations géométriques.Surfaces +Properties : + Surf0002 : GeomSurface + Surf0003 : GeomSurface + Surf0004 : GeomSurface + Surf0005 : GeomSurface +Properties sets : + SerializedRepresentation Volumes +Path : Description.Relations géométriques.Volumes +Properties : + Vol0000 : GeomVolume +Properties sets : + SerializedRepresentation Relations vers des groupes +Path : Description.Relations vers des groupes +Properties : +Properties sets : + SerializedRepresentation Groupes 2D +Path : Description.Relations vers des groupes.Groupes 2D +Properties : + Hors_Groupe_2D : Group2D +Properties sets : + SerializedRepresentation Propriétés OCC +Path : Description.Propriétés OCC +Properties : + HashCode : 126236801 +Properties sets : + SerializedRepresentation Propriétés géométriques +Path : Description.Propriétés géométriques +Properties : + Aire : 1.000000e+00 + Précision : 1.000000e-07 + Type : plan +Properties sets : \ No newline at end of file diff --git a/test_link/test_description_vol0000.txt b/test_link/test_description_vol0000.txt new file mode 100644 index 00000000..1fabc258 --- /dev/null +++ b/test_link/test_description_vol0000.txt @@ -0,0 +1,93 @@ +SerializedRepresentation Description +Path : Description +Properties : + Relations topologiques : Aucune +Properties sets : + SerializedRepresentation Propriétés génériques +Path : Description.Propriétés génériques +Properties : + Nom unique : GeomVolume_Vol0000 + Identifiant unique : 1 + Type : GeomVolume + Dimension : 3 + Est détruit : false + Est visible : false +Properties sets : + SerializedRepresentation Boite englobante +Path : Description.Propriétés génériques.Boite englobante +Properties : + X min : -1e-7 + X max : 1.0000001 + Y min : -1e-7 + Y max : 1.0000001 + Z min : -1e-7 + Z max : 1.0000001 +Properties sets : + SerializedRepresentation Relations géométriques +Path : Description.Relations géométriques +Properties : +Properties sets : + SerializedRepresentation Sommets +Path : Description.Relations géométriques.Sommets +Properties : + Pt0000 : GeomVertex + Pt0001 : GeomVertex + Pt0002 : GeomVertex + Pt0003 : GeomVertex + Pt0004 : GeomVertex + Pt0005 : GeomVertex + Pt0006 : GeomVertex + Pt0007 : GeomVertex +Properties sets : + SerializedRepresentation Courbes +Path : Description.Relations géométriques.Courbes +Properties : + Crb0000 : GeomCurve + Crb0001 : GeomCurve + Crb0002 : GeomCurve + Crb0003 : GeomCurve + Crb0004 : GeomCurve + Crb0005 : GeomCurve + Crb0006 : GeomCurve + Crb0007 : GeomCurve + Crb0008 : GeomCurve + Crb0009 : GeomCurve + Crb0010 : GeomCurve + Crb0011 : GeomCurve +Properties sets : + SerializedRepresentation Surfaces +Path : Description.Relations géométriques.Surfaces +Properties : + Surf0000 : GeomSurface + Surf0001 : GeomSurface + Surf0002 : GeomSurface + Surf0003 : GeomSurface + Surf0004 : GeomSurface + Surf0005 : GeomSurface +Properties sets : + SerializedRepresentation Relations vers des groupes +Path : Description.Relations vers des groupes +Properties : +Properties sets : + SerializedRepresentation Groupes 3D +Path : Description.Relations vers des groupes.Groupes 3D +Properties : + Hors_Groupe_3D : Group3D +Properties sets : + SerializedRepresentation Propriétés OCC +Path : Description.Propriétés OCC +Properties : + HashCode : 1386224161 +Properties sets : + SerializedRepresentation Propriétés géométriques +Path : Description.Propriétés géométriques +Properties : + Volume : 1.000000e+00 + Type : boîte + X min : 0 + Y min : 0 + Z min : 0 + Longueur en X : 1 + Longueur en Y : 1 + Longueur en Z : 1 +Properties sets : \ No newline at end of file diff --git a/test_link/test_extrusion.py b/test_link/test_extrusion.py index 4b54416c..6f2fc969 100644 --- a/test_link/test_extrusion.py +++ b/test_link/test_extrusion.py @@ -122,7 +122,7 @@ def test_makeExtrude_groups(): # Extrusion de Surf0000 gm.makeExtrude (["Surf0000"], Mgx3D.Vector(0, 0, 5), False) - assert gm.getInfos("Vol0000",3).groupsName() == ['PLAN'] + assert gm.getInfos("Vol0000",3).groups() == ['PLAN'] assert sorted(grm.getGeomSurfaces("PLAN", 2)) == ['Surf0001', 'Surf0002', 'Surf0003', 'Surf0004'] assert sorted(grm.getGeomSurfaces("Hors_Groupe_2D", 2)) == ['Surf0005', 'Surf0006'] assert sorted(grm.getGeomCurves("PLAN", 1)) == ['Crb0004', 'Crb0005', 'Crb0006', 'Crb0007'] @@ -140,7 +140,7 @@ def test_makeRevol_groups(): # Révolution de Surf0000 gm.makeRevol (["Surf0000"], Mgx3D.RotX(120), False) - assert gm.getInfos("Vol0000",3).groupsName() == ['PLAN'] + assert gm.getInfos("Vol0000",3).groups() == ['PLAN'] assert sorted(grm.getGeomSurfaces("PLAN", 2)) == ['Surf0001', 'Surf0002', 'Surf0003'] assert sorted(grm.getGeomSurfaces("Hors_Groupe_2D", 2)) == ['Surf0004', 'Surf0005'] assert sorted(grm.getGeomCurves("PLAN", 1)) == ['Crb0004', 'Crb0005'] @@ -158,7 +158,7 @@ def test_makeRevol_groups(): # Révolution de Surf0000 gm.makeRevol (["Surf0000"], Mgx3D.RotX(180), False) - assert gm.getInfos("Vol0000",3).groupsName() == ['PLAN'] + assert gm.getInfos("Vol0000",3).groups() == ['PLAN'] assert sorted(grm.getGeomSurfaces("PLAN", 2)) == ['Surf0001', 'Surf0002', 'Surf0003'] assert sorted(grm.getGeomSurfaces("PZ0_PLAN", 2)) == ['Surf0004', 'Surf0005'] assert sorted(grm.getGeomCurves("PLAN", 1)) == ['Crb0004', 'Crb0005'] diff --git a/test_link/test_groups.py b/test_link/test_groups.py index 29cb8f01..5bd6ea27 100644 --- a/test_link/test_groups.py +++ b/test_link/test_groups.py @@ -49,7 +49,7 @@ def test_group_box(): def assert_all(ctx, block, group_names): block_info = ctx.getTopoManager().getInfos(block, 3) # Lien explicite block -> group - assert 0 == len(block_info.groupsName()) + assert 0 == len(block_info.groups()) for group_name in group_names: # Lien implicite group -> block assert block in ctx.getGroupManager().getTopoBlocks(group_name, 3) @@ -60,12 +60,12 @@ def assert_all(ctx, block, group_names): # Lien implicite group -> vertices assert set(block_info.vertices()) == set(ctx.getGroupManager().getTopoVertices(group_name, 3)) - vol = block_info.geomEntity() + vol = block_info.geom_entity vol_info = ctx.getGeomManager().getInfos(vol, 3) - assert len(group_names) == len(vol_info.groupsName()) + assert len(group_names) == len(vol_info.groups()) for group_name in group_names: # Lien explicite volume -> group - assert group_name in vol_info.groupsName() + assert group_name in vol_info.groups() # Lien explicite group -> volume assert vol in ctx.getGroupManager().getGeomVolumes(group_name, 3) # Lien implicite group -> surfaces @@ -82,13 +82,13 @@ def test_new_box(): ctx.getTopoManager().newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10, "aaa") vol_info = ctx.getGeomManager().getInfos("Vol0000",3) # Les entités de dimension inférieure à 3 sont affectées au groupe aaa de manière implicite - assert "aaa" in vol_info.groupsName() + assert "aaa" in vol_info.groups() surf_info = ctx.getGeomManager().getInfos("Surf0000",2) - assert "aaa" not in surf_info.groupsName() + assert "aaa" not in surf_info.groups() crb_info = ctx.getGeomManager().getInfos("Crb0000",1) - assert "aaa" not in crb_info.groupsName() + assert "aaa" not in crb_info.groups() pt_info = ctx.getGeomManager().getInfos("Pt0000",0) - assert "aaa" not in pt_info.groupsName() + assert "aaa" not in pt_info.groups() def test_section_by_plane(): ctx = Mgx3D.getStdContext() @@ -96,18 +96,18 @@ def test_section_by_plane(): # Création d'une boite avec une topologie ctx.getTopoManager().newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10, "box") vol_info = ctx.getGeomManager().getInfos("Vol0000",3) - assert "box" in vol_info.groupsName() + assert "box" in vol_info.groups() # Section par un plan entre géométries avec topologies ctx.getGeomManager ( ).sectionByPlane (["Vol0000"], Mgx3D.Plane(Mgx3D.Point(0, 0, .5), Mgx3D.Vector(0, 0, 1)), "aaa") # Les entités de dimension inférieure à 2 sont affectées au groupe aaa de manière explicite vol_info = ctx.getGeomManager().getInfos("Vol0001",3) - assert "box" in vol_info.groupsName() + assert "box" in vol_info.groups() surf_info = ctx.getGeomManager().getInfos("Surf0010",2) - assert "aaa" in surf_info.groupsName() + assert "aaa" in surf_info.groups() crb_info = ctx.getGeomManager().getInfos("Crb0014",1) - assert "aaa" in crb_info.groupsName() + assert "aaa" in crb_info.groups() pt_info = ctx.getGeomManager().getInfos("Pt0008",0) - assert "aaa" in pt_info.groupsName() + assert "aaa" in pt_info.groups() # Destruction de Pt0008 ctx.getGeomManager().destroy(["Pt0008"], False) assert "DETRUIT" in ctx.getGroupManager().getInfos("aaa", 2) @@ -116,17 +116,17 @@ def test_section_by_plane(): ctx.undo() # Les entités de dimension inférieure à 2 sont affectées au groupe aaa de manière explicite vol_info = ctx.getGeomManager().getInfos("Vol0001",3) - assert "box" in vol_info.groupsName() + assert "box" in vol_info.groups() surf_info = ctx.getGeomManager().getInfos("Surf0010",2) - assert "aaa" in surf_info.groupsName() + assert "aaa" in surf_info.groups() crb_info = ctx.getGeomManager().getInfos("Crb0014",1) - assert "aaa" in crb_info.groupsName() + assert "aaa" in crb_info.groups() pt_info = ctx.getGeomManager().getInfos("Pt0008",0) - assert "aaa" in pt_info.groupsName() + assert "aaa" in pt_info.groups() # Annulation de : Section par un plan entre géométries avec topologies ctx.undo() vol_info = ctx.getGeomManager().getInfos("Vol0000",3) - assert "box" in vol_info.groupsName() + assert "box" in vol_info.groups() assert "DETRUIT" in ctx.getGroupManager().getInfos("aaa", 1) assert "DETRUIT" in ctx.getGroupManager().getInfos("aaa", 2) @@ -140,11 +140,11 @@ def test_new_vertices_curves_and_planar_surface(): # Les entités de dimension inférieure à 2 sont affectées au groupe aaa de manière explicite # Cette commande crée 4 points + 4 courbes + 1 surface surf_info = ctx.getGeomManager().getInfos("Surf0006",2) - assert "aaa" in surf_info.groupsName() + assert "aaa" in surf_info.groups() crb_info = ctx.getGeomManager().getInfos("Crb0012",1) - assert "aaa" in crb_info.groupsName() + assert "aaa" in crb_info.groups() pt_info = ctx.getGeomManager().getInfos("Pt0008",0) - assert "aaa" in pt_info.groupsName() + assert "aaa" in pt_info.groups() def test_new_planar_surface(): ctx = Mgx3D.getStdContext() @@ -156,11 +156,11 @@ def test_new_planar_surface(): # Les entités de dimension inférieure à 2 sont affectées au groupe aaa de manière implicite # Cette commande crée 1 surface à partir de 4 courbes existantes surf_info = ctx.getGeomManager().getInfos("Surf0006",2) - assert "aaa" in surf_info.groupsName() + assert "aaa" in surf_info.groups() crb_info = ctx.getGeomManager().getInfos("Crb0002",1) - assert "aaa" not in crb_info.groupsName() + assert "aaa" not in crb_info.groups() pt_info = ctx.getGeomManager().getInfos("Pt0002",0) - assert "aaa" not in pt_info.groupsName() + assert "aaa" not in pt_info.groups() # Issue #215 def test_undo_add_to_group(): diff --git a/test_link/test_join_and_glue.py b/test_link/test_join_and_glue.py index 420bf7e6..a8d3ff0e 100644 --- a/test_link/test_join_and_glue.py +++ b/test_link/test_join_and_glue.py @@ -19,8 +19,8 @@ def test_join_surfaces(): assert "Surf0003" not in gm.getSurfaces() assert "Surf0009" not in gm.getSurfaces() assert "Surf0012" in gm.getSurfaces() - assert "Surf0012" == tm.getInfos("Fa0003", 2).geomEntity() - assert "Surf0012" == tm.getInfos("Fa0009", 2).geomEntity() + assert "Surf0012" == tm.getInfos("Fa0003", 2).geom_entity + assert "Surf0012" == tm.getInfos("Fa0009", 2).geom_entity def test_glue_with_joined_surfaces(capfd): ctx = Mgx3D.getStdContext() diff --git a/test_link/test_split_faces.py b/test_link/test_split_faces.py new file mode 100644 index 00000000..c6d467c5 --- /dev/null +++ b/test_link/test_split_faces.py @@ -0,0 +1,241 @@ +import pyMagix3D as Mgx3D +import math + +def test_split_faces2D_1(capfd): + ctx = Mgx3D.getStdContext() + gm = ctx.getGeomManager() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création du sommet Pt0000 + gm.newVertex (Mgx3D.Point(0, 0, 0)) + # Création du sommet Pt0001 + gm.newVertex (Mgx3D.Point(0, 1, 0)) + # Création du sommet Pt0002 + gm.newVertex (Mgx3D.Point(1, 1, 0)) + # Création du sommet Pt0003 + gm.newVertex (Mgx3D.Point(1, 0, 0)) + # Création d'une surface avec vecteur de points + gm.newVerticesCurvesAndPlanarSurface ([Mgx3D.Point(0, 1, 0),Mgx3D.Point(1, 1, 0),Mgx3D.Point(1, 0, 0),Mgx3D.Point(0, 0, 0)], "") + # Création d'une face topologique structurée sur une géométrie (Surf0000) + tm.newStructuredTopoOnGeometry ("Surf0000") + assert tm.getNbFaces()==1 + + # Découpage des faces 2D structurées Fa0000 suivant l'arête Ar0001 avec comme ratio 5.000000e-01 + tm.splitFaces (["Fa0000"], "Ar0001", .5, .5) + assert tm.getNbFaces()==2 + assertVertex(tm, "Som0004", 1, 0.5, 0) + +def test_split_faces2D_2(capfd): + ctx = Mgx3D.getStdContext() + gm = ctx.getGeomManager() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création d'une boite avec une topologie + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) + # Suppression d'entités géométriques et suppression des entités topologiques dépendantes + gm.destroyWithTopo(["Vol0000"], False) + + # Découpage de 2 faces par l'arete opposée aux deux faces + # Découpage des faces 2D structurées Fa0000 Fa0005 suivant l'arête Ar0003 avec comme ratio 3.000000e-01 + tm.splitFaces (["Fa0000","Fa0005"], "Ar0003", .3, .5) + assert tm.getNbFaces() == 8 + ctx.undo() + assert tm.getNbFaces() == 6 + + # Découpage de 2 faces par l'arete adjacente aux deux faces + # Découpage des faces 2D structurées Fa0005 Fa0001 suivant l'arête Ar0005 avec comme ratio 5.000000e-01 + tm.splitFaces (["Fa0005","Fa0001"], "Ar0005", .5, .5) + assert tm.getNbFaces() == 8 + ctx.undo() + assert tm.getNbFaces() == 6 + + # Découpage des faces 2D structurées Fa0005 Fa0001 Fa0004 Fa0000 suivant l'arête Ar0001 avec comme ratio 3.000000e-01 + tm.splitFaces (["Fa0005","Fa0001","Fa0004","Fa0000"], "Ar0001", .3, .5) + assert tm.getNbFaces() == 10 + +def test_split_faces2D_3(capfd): + ctx = Mgx3D.getStdContext() + gm = ctx.getGeomManager() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création d'une boite avec une topologie + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) + # Suppression d'entités géométriques et suppression des entités topologiques dépendantes + gm.destroyWithTopo(["Vol0000"], False) + # Découpage de toutes les faces 2D structurées + tm.splitAllFaces ("Ar0005", .5, .5) + assert tm.getNbFaces() == 10 + +def test_split_faces2D_4(capfd): + # Test de extendSplitFaces avec une face dégénérée + ctx = Mgx3D.getStdContext() + gm = ctx.getGeomManager() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création d'une boite avec une topologie + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) + # Suppression d'entités géométriques et suppression des liens topologiques + gm.destroy(["Vol0000"], True) + # Destruction des entités topologiques Bl0000 + ctx.getTopoManager ( ).destroy (["Bl0000"], False) + # Découpage de la face Fa0000 + tm.splitFaces (["Fa0000"], "Ar0000", .5, 0, True) + assert tm.getNbFaces() == 7 + # On attaque depuis la face opposée à la dégénerescence + # Découpage de la face Fa0003 par prolongation + tm.extendSplitFace ("Fa0003", "Som0009") + assert tm.getNbFaces() == 8 + +def test_split_faces2D_4(capfd): + # Test de splitFaces avec o-grid + ctx = Mgx3D.getStdContext() + gm = ctx.getGeomManager() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création du sommet Pt0000 + gm.newVertex (Mgx3D.Point(0, 0, 0)) + # Création du sommet Pt0001 + gm.newVertex (Mgx3D.Point(1, 0, 0)) + # Création du sommet Pt0002 + gm.newVertex (Mgx3D.Point(2, 0, 0)) + # Création du segment Crb0000 + gm.newSegment("Pt0000", "Pt0001") + # Création du segment Crb0001 + gm.newSegment("Pt0001", "Pt0002") + # Création de l'arc de cercle Crb0002 + gm.newArcCircle("Pt0001", "Pt0002", "Pt0000", True) + # Création de la surface Surf0000 + ctx.getGeomManager ( ).newPlanarSurface (["Crb0001","Crb0002","Crb0000"], "") + # Création d'une face topologique structurée sur une géométrie (Surf0000) + tm.newStructuredTopoOnGeometry ("Surf0000") + # Découpage de toutes les faces 2D structurées + tm.splitAllFaces ("Ar0001", .2, .7) + assert tm.getNbFaces() == 4 + assertVertex(tm, "Som0006", 1.5663118960624631, 0, 0) + assertVertex(tm, "Som0007", 1.5663118960624631, 0.4114496766047312, 0) + +def test_split_faces3D_1(capfd): + ctx = Mgx3D.getStdContext() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création d'une boite avec une topologie + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) + # Découpage de la face Fa0005 + tm.splitFaces (["Fa0005"], "Ar0005", .3, 0, True) + assert tm.getNbFaces() == 7 + +def test_split_faces3D_2(capfd): + ctx = Mgx3D.getStdContext() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création d'une boite avec une topologie + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) + # Découpage des faces Fa0005 Fa0000 suivant l'arête Ar0005 avec comme ratio 3.000000e-01 + tm.splitFaces (["Fa0005","Fa0000"], "Ar0005", .3, .5) + assert tm.getNbFaces() == 8 + ctx.undo() + assert tm.getNbFaces() == 6 + + # cas où l'arete n'est pas adjacente à une des faces et qu'on ne peut pas itérer + # Une seule face découpée + # Découpage des faces Fa0001 Fa0000 suivant l'arête Ar0005 avec comme ratio 3.000000e-01 + tm.splitFaces (["Fa0001","Fa0000"], "Ar0005", .3, .5) + assert tm.getNbFaces() == 7 + +def test_split_faces3D_3(capfd): + ctx = Mgx3D.getStdContext() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création d'une boite avec une topologie + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) + tm.snapVertices ("Som0007", "Som0006", True) + # découpage d'une face dégenérée + tm.splitFaces (["Fa0001"], "Ar0007", .3, 0, True) + assert tm.getNbFaces() == 7 + +def test_projection_3d(capfd): + ctx = Mgx3D.getStdContext() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création d'une boite avec une topologie + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) + + # Découpage des faces structurées Fa0001 suivant l'arête Ar0007 avec comme ratio 6.200000e-01 + tm.splitFaces (["Fa0001"], "Ar0007", .62, .5, False) + assertVertex(tm, "Som0008", 1, 0.62, 0) + # Annulation de : Découpage des faces structurées Fa0001 suivant l'arête Ar0007 avec comme ratio 6.200000e-01 + ctx.undo() + # Découpage des faces structurées Fa0001 suivant l'arête Ar0007 avec comme ratio 6.200000e-01 + tm.splitFaces (["Fa0001"], "Ar0007", .62, .5, True) + assertVertex(tm, "Som0008", 1, 0.6, 0) + +def test_projection_2d(capfd): + ctx = Mgx3D.getStdContext() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création d'un bloc unitaire mis dans le groupe aaa + tm.newFreeTopoInGroup ("aaa", 2) + # Changement de discrétisation pour Ar0003 + emp = Mgx3D.EdgeMeshingPropertyUniform(2) + tm.setParallelMeshingProperty (emp,"Ar0003") + # Découpage de la face Fa0000 + tm.splitFaces (["Fa0000"], "Ar0003", .7, 0, True) + assertVertex(tm, "Som0005", 0, 0.5, 0) + + # Annulation de : Découpage des faces structurées Fa0000 suivant l'arête Ar0003 avec comme ratio 7.000000e-01 + ctx.undo() + # Découpage de la face Fa0000 + tm.splitFaces (["Fa0000"], "Ar0003", .7, 0, False) + assertCloseVertex(tm, "Som0005", 0, 0.3, 0) + + # Annulation de : Découpage des faces structurées Fa0000 suivant l'arête Ar0003 avec comme ratio 7.000000e-01 + ctx.undo() + # Changement de discrétisation pour Ar0003 + emp = Mgx3D.EdgeMeshingPropertyGeometric(20, 1.1) + tm.setParallelMeshingProperty (emp,"Ar0003") + # Découpage de la face Fa0000 + tm.splitFaces (["Fa0000"], "Ar0003", .5, 0, True) + assertCloseVertex(tm, "Som0005", 0, 0.2782614533742, 0) + + # Annulation de : Création du maillage pour toutes les faces + ctx.undo() + # Découpage de la face Fa0000 + tm.splitFaces (["Fa0000"], "Ar0003", .5, 0, False) + assertVertex(tm, "Som0005", 0, 0.5, 0) + +def test_projection_2d_2faces(capfd): + ctx = Mgx3D.getStdContext() + tm = ctx.getTopoManager() + ctx.clearSession() # Clean the session after the previous test + # Création d'un bloc unitaire mis dans le groupe aaa + tm.newFreeTopoInGroup ("aaa", 2) + # Création d'un sommet géométrique par coordonnées + tm.newTopoVertex (Mgx3D.Point(2, 0, 0),"bbb") + # Création d'un sommet géométrique par coordonnées + tm.newTopoVertex (Mgx3D.Point(2, 1, 0),"bbb") + # Création d'une face topologique structurée + tm.newTopoEntity (["Som0000", "Som0004", "Som0005", "Som0003"], 2, "bbb") + # Changement de discrétisation pour les arêtes Ar0003 + emp = Mgx3D.EdgeMeshingPropertyGeometric(10, 1.1) + tm.setMeshingProperty (emp, ["Ar0003"]) + # Découpage de la face Fa0000 + tm.splitFaces (["Fa0000"], "Ar0001", .5, 0, True) + assertCloseVertex(tm, "Som0007", 1, 0.383066910297221, 0) + # Découpage de la face Fa0001 + tm.splitFaces (["Fa0001"], "Ar0005", .5, 0, False) + assertVertex(tm, "Som0007", 1, 0.5, 0) + # Pourquoi déplace-t-on le sommet au lieu d'en recréer un ? + # Si on undo, le sommet ne revient pas à sa place originelle -> c'est un bug + # Bug affichage. Pb de rafraîchissement. En les désaffichant et réaffichant c'est bon + +def assertVertex(tm, vname, x, y, z): + p = tm.getCoord(vname) + assert p.getX() == x + assert p.getY() == y + assert p.getZ() == z + +def assertCloseVertex(tm, vname, x, y, z): + p = tm.getCoord(vname) + assert math.isclose(p.getX(), x, abs_tol=1e-15) + assert math.isclose(p.getY(), y, abs_tol=1e-15) + assert math.isclose(p.getZ(), z, abs_tol=1e-15) \ No newline at end of file