Skip to content

Commit 95f3ec0

Browse files
authored
Merge pull request #136 from LIHPC-Computational-Geometry/topology_import_V0
Topology import v0
2 parents 209da86 + b7db32b commit 95f3ec0

12 files changed

+649
-10
lines changed

src/Core/Topo/CommandExportBlocks.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Topo {
1010
/*----------------------------------------------------------------------------*/
1111
CommandExportBlocks::
1212
CommandExportBlocks(Internal::Context &context, const std::string &fileName)
13-
: Internal::CommandInternal(context, "Export des Blocs"), m_impl(context, fileName)
13+
: Internal::CommandInternal(context, "Export des Blocs"),m_filename(fileName), m_impl(context, fileName)
1414
{}
1515
/*----------------------------------------------------------------------------*/
1616
CommandExportBlocks::~CommandExportBlocks()
@@ -19,6 +19,19 @@ CommandExportBlocks::~CommandExportBlocks()
1919
void CommandExportBlocks::
2020
internalExecute()
2121
{
22+
23+
std::string ext;
24+
int i = m_filename.rfind('.', m_filename.length());
25+
if (i != std::string::npos) {
26+
ext = m_filename.substr(i+1, m_filename.length() - i);
27+
}
28+
29+
if(ext != "blk"){
30+
TkUtil::UTF8String message (TkUtil::Charset::UTF_8);
31+
message<<"Erreur dans l'extension du fichier, merci d'utiliser \".blk\"";
32+
throw TkUtil::Exception (message);
33+
34+
}
2235
// écriture du STEP
2336
m_impl.perform(&getInfoCommand());
2437
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// Created by calderans on 4/3/25.
3+
//
4+
5+
#include "Topo/CommandImportBlocks.h"
6+
/*----------------------------------------------------------------------------*/
7+
#include <TkUtil/Exception.h>
8+
/*----------------------------------------------------------------------------*/
9+
namespace Mgx3D {
10+
/*----------------------------------------------------------------------------*/
11+
namespace Topo {
12+
13+
/*----------------------------------------------------------------------------*/
14+
CommandImportBlocks::
15+
CommandImportBlocks(Internal::Context& c, const std::string& n)
16+
: CommandCreateTopo(c, "Import (Topo) Mdl"), m_filename(n)
17+
{
18+
m_impl = new ImportBlocksImplementation(c, &getInfoCommand(), m_filename);
19+
}
20+
/*----------------------------------------------------------------------------*/
21+
CommandImportBlocks::~CommandImportBlocks()
22+
{
23+
if(m_impl)
24+
delete m_impl;
25+
}
26+
/*----------------------------------------------------------------------------*/
27+
void CommandImportBlocks::
28+
internalExecute()
29+
{
30+
m_impl->internalExecute();
31+
32+
33+
for(auto te : getInfoCommand().getTopoInfoEntity()){
34+
if(te.first->getDim() == 0){
35+
getTopoManager().add((Vertex*)te.first);
36+
}else if(te.first->getDim() == 1){
37+
getTopoManager().add((CoEdge*)te.first);
38+
}else if(te.first->getDim() == 2){
39+
getTopoManager().add((CoFace*)te.first);
40+
}else if(te.first->getDim() == 3){
41+
getTopoManager().add((Block*)te.first);
42+
}
43+
}
44+
45+
}
46+
/*----------------------------------------------------------------------------*/
47+
void CommandImportBlocks::getPreviewRepresentation(Utils::DisplayRepresentation& dr)
48+
{
49+
MGX_FORBIDDEN("getPreviewRepresentation non prévu");
50+
}
51+
/*----------------------------------------------------------------------------*/
52+
} // end namespace Topo
53+
/*----------------------------------------------------------------------------*/
54+
} // end namespace Mgx3D
55+
/*----------------------------------------------------------------------------*/

src/Core/Topo/ExportBlocksImplementation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ ExportBlocksImplementation(Internal::Context& c, const std::string& n)
1515
: m_context(c), m_filename(n)
1616
{}
1717
/*----------------------------------------------------------------------------*/
18-
ExportBlocksImplementation::
19-
~ExportBlocksImplementation()
20-
{}
2118
/*----------------------------------------------------------------------------*/
2219
void ExportBlocksImplementation::perform(Internal::InfoCommand* icmd)
2320
{
@@ -105,7 +102,7 @@ void ExportBlocksImplementation::writeEdges(std::ofstream &str, std::vector<Topo
105102
for(auto e_name : dynamic_cast<EdgeMeshingPropertyGlobalInterpolate*>(prop)->getFirstCoEdges()){
106103
str << m_edge_ids_mapping[e_name] << " ";
107104
}
108-
str << "] ";
105+
str << "] [ ";
109106
for(auto e_name : dynamic_cast<EdgeMeshingPropertyGlobalInterpolate*>(prop)->getSecondCoEdges()){
110107
str << m_edge_ids_mapping[e_name] << " ";
111108
}
@@ -181,6 +178,7 @@ void ExportBlocksImplementation::writeFaces(std::ofstream &str, std::vector<Topo
181178
void ExportBlocksImplementation::writeBlocks(std::ofstream &str, std::vector<Topo::Block*> blocks) {
182179
str << "BLOCKS " << blocks.size() << "\n";
183180
for(auto b : blocks){
181+
184182
int v0 = m_node_ids_mapping[b->getVertex(0)->getName()];
185183
int v1 = m_node_ids_mapping[b->getVertex(1)->getName()];
186184
int v2 = m_node_ids_mapping[b->getVertex(2)->getName()];

0 commit comments

Comments
 (0)