Skip to content

Commit

Permalink
Remove TopoDS_Wire creation at import (IGES, STEP, CATIA, BREP).
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandaisb committed Feb 4, 2025
1 parent ef50e22 commit 48a04f0
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 428 deletions.
3 changes: 1 addition & 2 deletions src/Core/Geom/CommandImportBREP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ namespace Mgx3D {
namespace Geom {
/*----------------------------------------------------------------------------*/
CommandImportBREP::
CommandImportBREP(Internal::Context& c, const std::string& n, const bool testVolumicProperties, const bool splitCompoundCurves)
CommandImportBREP(Internal::Context& c, const std::string& n, const bool testVolumicProperties)
: CommandCreateGeom(c, "Import BREP"), m_filename(n)
{
m_impl = new ImportBREPImplementation(c, &getInfoCommand(), m_filename);
m_impl->setSplitCompoundCurves(splitCompoundCurves);
m_impl->setTestVolumicProperties(testVolumicProperties);
}
/*----------------------------------------------------------------------------*/
Expand Down
3 changes: 1 addition & 2 deletions src/Core/Geom/CommandImportCATIA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ class Surface;
class Volume;
/*----------------------------------------------------------------------------*/
CommandImportCATIA::
CommandImportCATIA(Internal::Context& c, const std::string& n, const bool testVolumicProperties, const bool splitCompoundCurves)
CommandImportCATIA(Internal::Context& c, const std::string& n, const bool testVolumicProperties)
: CommandCreateGeom(c, "Import CATIA"), m_filename(n)
{
m_impl = new ImportCATIAImplementation(c, &getInfoCommand(), m_filename);
m_impl->setSplitCompoundCurves(splitCompoundCurves);
m_impl->setTestVolumicProperties(testVolumicProperties);
}
/*----------------------------------------------------------------------------*/
Expand Down
3 changes: 1 addition & 2 deletions src/Core/Geom/CommandImportIGES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ class Surface;
class Volume;
/*----------------------------------------------------------------------------*/
CommandImportIGES::
CommandImportIGES(Internal::Context& c, const std::string& n, const bool splitCompoundCurves)
CommandImportIGES(Internal::Context& c, const std::string& n)
: CommandCreateGeom(c, "Import IGES"), m_filename(n)
{
m_impl = new ImportIGESImplementation(c, &getInfoCommand(), m_filename);
m_impl->setSplitCompoundCurves(splitCompoundCurves);
}
/*----------------------------------------------------------------------------*/
CommandImportIGES::~CommandImportIGES()
Expand Down
3 changes: 1 addition & 2 deletions src/Core/Geom/CommandImportSTEP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ class Surface;
class Volume;
/*----------------------------------------------------------------------------*/
CommandImportSTEP::
CommandImportSTEP(Internal::Context& c, const std::string& n, const bool testVolumicProperties, const bool splitCompoundCurves)
CommandImportSTEP(Internal::Context& c, const std::string& n, const bool testVolumicProperties)
: CommandCreateGeom(c, "Import STEP"), m_filename(n)
{
m_impl = new ImportSTEPImplementation(c, &getInfoCommand(), m_filename);
m_impl->setSplitCompoundCurves(splitCompoundCurves);
m_impl->setTestVolumicProperties(testVolumicProperties);
}
/*----------------------------------------------------------------------------*/
Expand Down
22 changes: 0 additions & 22 deletions src/Core/Geom/EntityFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1531,17 +1531,6 @@ Curve* EntityFactory::newOCCCurve(TopoDS_Edge& e)
return curve;
}
/*----------------------------------------------------------------------------*/
Curve* EntityFactory::newOCCCurve(TopoDS_Wire& w)
{
Curve* curve = new Curve(m_context,
m_context.newProperty(Utils::Entity::GeomCurve),
m_context.newDisplayProperties(Utils::Entity::GeomCurve),
new GeomProperty(), new OCCGeomRepresentation(m_context, w));
CHECK_NULL_PTR_ERROR (curve)
m_context.newGraphicalRepresentation (*curve);
return curve;
}
/*----------------------------------------------------------------------------*/
Curve* EntityFactory::newOCCCompositeCurve(std::vector<TopoDS_Edge>& v_ds_edge,
Utils::Math::Point& extremaFirst, Utils::Math::Point& extremaLast)
{
Expand Down Expand Up @@ -1638,17 +1627,6 @@ Curve* EntityFactory::newOCCCompositeCurve(std::vector<TopoDS_Edge>& v_ds_edge,
return curve;
}
/*----------------------------------------------------------------------------*/
//Curve* EntityFactory::newOCCCurve(TopoDS_Wire& w)
//{
// Curve* curve = new Curve(m_context,
// m_context.newProperty(Utils::Entity::GeomCurve),
// m_context.newDisplayProperties(Utils::Entity::GeomCurve),
// new GeomProperty(), new OCCGeomRepresentation(m_context, w));
// CHECK_NULL_PTR_ERROR (curve)
// m_context.newGraphicalRepresentation (*curve);
// return curve;
//}
/*----------------------------------------------------------------------------*/
//#define _DEBUG_EDGEPROJECTION
Curve* EntityFactory::newCurveByEdgeProjectionOnSurface(const Utils::Math::Point& P1,
const Utils::Math::Point& P2,
Expand Down
77 changes: 19 additions & 58 deletions src/Core/Geom/GeomImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ GeomImport(Internal::Context& c, Internal::InfoCommand* icmd,
const std::string& n, const bool onlySolidsAndFaces)
: GeomModificationBaseClass(c /*on ne garde pas les entités initiales*/),
m_icmd(icmd), m_filename(n), m_onlySolidsAndFaces(onlySolidsAndFaces),
m_testVolumicProperties(true),
m_splitCompondCurves(false)
m_testVolumicProperties(true)
{
// récupération du nom du fichier sans chemin ni extension
std::string suffix = m_filename;
Expand Down Expand Up @@ -267,62 +266,24 @@ void GeomImport::add(TopoDS_Shape& AShape, const std::string& AName)
break;
case TopAbs_WIRE:
{
if (m_splitCompondCurves){
// version avec courbes multiples
TopoDS_Wire aWire= TopoDS::Wire(AShape);
TopExp_Explorer ex;
for (ex.Init(aWire,TopAbs_EDGE); ex.More(); ex.Next())
{
TopoDS_Edge aEdge = TopoDS::Edge(ex.Current());
Curve* curve=EntityFactory(m_context).newOCCCurve(TopoDS::Edge(aEdge));
curvs.push_back(curve);
TkUtil::UTF8String name (TkUtil::Charset::UTF_8);
name << AName<< "-edge";
addToGroup(curve, AName);
store(curve);
}
splitManyCurves(curvs, verts);
for(unsigned int i=0;i<verts.size();i++){
store(verts[i]);
addToGroup(verts[i],"");
}
}
else {
Curve* curve=EntityFactory(m_context).newOCCCurve(TopoDS::Wire(AShape));
addToGroup(curve, AName);
curve->split(verts);
store(curve);
for(unsigned int i=0;i<verts.size();i++)
store(verts[i]);
}

// TopoDS_Wire aWire= TopoDS::Wire(AShape);
// TopExp_Explorer ex;
// std::vector<TopoDS_Edge> v_ds_edge;
// for (ex.Init(aWire,TopAbs_EDGE); ex.More(); ex.Next()){
// v_ds_edge.push_back(TopoDS::Edge(ex.Current()));
// }
// Utils::Math::Point pt1, pt2;
// {
// BRepAdaptor_Curve brepCurve(v_ds_edge.front());
// gp_Pnt res;
// res = brepCurve.Value(brepCurve.FirstParameter());
// pt1.setXYZ(res.X(), res.Y(), res.Z());
// }
// {
// BRepAdaptor_Curve brepCurve(v_ds_edge.back());
// gp_Pnt res;
// res = brepCurve.Value(brepCurve.LastParameter());
// pt2.setXYZ(res.X(), res.Y(), res.Z());
// }
//
// Curve* curve=EntityFactory(m_context).newOCCCompositeCurve(v_ds_edge, pt1, pt2);
// addToGroup(curve, AName);
// curve->split(verts);
// store(curve);
// for(unsigned int i=0;i<verts.size();i++)
// store(verts[i]);

// version avec courbes multiples
TopoDS_Wire aWire= TopoDS::Wire(AShape);
TopExp_Explorer ex;
for (ex.Init(aWire,TopAbs_EDGE); ex.More(); ex.Next())
{
TopoDS_Edge aEdge = TopoDS::Edge(ex.Current());
Curve* curve=EntityFactory(m_context).newOCCCurve(TopoDS::Edge(aEdge));
curvs.push_back(curve);
TkUtil::UTF8String name (TkUtil::Charset::UTF_8);
name << AName<< "-edge";
addToGroup(curve, AName);
store(curve);
}
splitManyCurves(curvs, verts);
for(unsigned int i=0;i<verts.size();i++){
store(verts[i]);
addToGroup(verts[i],"");
}
}
break;
case TopAbs_EDGE:
Expand Down
33 changes: 15 additions & 18 deletions src/Core/Geom/GeomManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3426,19 +3426,19 @@ common2DOnCopy(Geom::GeomEntity* entity1, Geom::GeomEntity* entity2, std::string
return cmdResult;
}
/*----------------------------------------------------------------------------*/
Internal::M3DCommandResultIfc* GeomManager::importBREP(std::string n, const bool testVolumicProperties, const bool splitCompoundCurves)
Internal::M3DCommandResultIfc* GeomManager::importBREP(std::string n, const bool testVolumicProperties)
{
TkUtil::UTF8String message (TkUtil::Charset::UTF_8);
message << "GeomManager::importBREP ("<<n<<")";
log (TkUtil::TraceLog (message, TkUtil::Log::TRACE_3));

//creation de la commande de création
CommandImportBREP *command = new CommandImportBREP(getLocalContext(), n, testVolumicProperties, splitCompoundCurves);
CommandImportBREP *command = new CommandImportBREP(getLocalContext(), n, testVolumicProperties);
// trace dans le script
TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8);
cmd << getContextAlias() << "." << "getGeomManager().importBREP(\""<<n<<"\"";
if (!testVolumicProperties || splitCompoundCurves)
cmd << (testVolumicProperties?", True":", False") << (splitCompoundCurves?", True":", False");
if (!testVolumicProperties)
cmd << (testVolumicProperties?", True":", False");
cmd << ")";
command->setScriptCommand(cmd);

Expand All @@ -3451,19 +3451,19 @@ Internal::M3DCommandResultIfc* GeomManager::importBREP(std::string n, const bool
return cmdResult;
}
/*----------------------------------------------------------------------------*/
Internal::M3DCommandResultIfc* GeomManager::importSTEP(std::string n, const bool testVolumicProperties, const bool splitCompoundCurves)
Internal::M3DCommandResultIfc* GeomManager::importSTEP(std::string n, const bool testVolumicProperties)
{
TkUtil::UTF8String message (TkUtil::Charset::UTF_8);
message << "GeomManager::importSTEP ("<<n<<")";
log (TkUtil::TraceLog (message, TkUtil::Log::TRACE_3));

//creation de la commande de création
CommandImportSTEP *command = new CommandImportSTEP(getLocalContext(), n, testVolumicProperties, splitCompoundCurves);
CommandImportSTEP *command = new CommandImportSTEP(getLocalContext(), n, testVolumicProperties);
// trace dans le script
TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8);
cmd << getContextAlias() << "." << "getGeomManager().importSTEP(\""<<n<<"\"";
if (!testVolumicProperties || splitCompoundCurves)
cmd << (testVolumicProperties?", True":", False") << (splitCompoundCurves?", True":", False");
if (!testVolumicProperties)
cmd << (testVolumicProperties?", True":", False");
cmd << ")";
command->setScriptCommand(cmd);

Expand Down Expand Up @@ -3499,20 +3499,17 @@ Internal::M3DCommandResultIfc* GeomManager::importSTL(std::string n)
return cmdResult;
}
/*----------------------------------------------------------------------------*/
Internal::M3DCommandResultIfc* GeomManager::importIGES(std::string n, const bool splitCompoundCurves)
Internal::M3DCommandResultIfc* GeomManager::importIGES(std::string n)
{
TkUtil::UTF8String message (TkUtil::Charset::UTF_8);
message << "GeomManager::importIGES ("<<n<<")";
log (TkUtil::TraceLog (message, TkUtil::Log::TRACE_3));

//creation de la commande de création
CommandImportIGES *command = new CommandImportIGES(getLocalContext(),n, splitCompoundCurves);
CommandImportIGES *command = new CommandImportIGES(getLocalContext(), n);
// trace dans le script
TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8);
cmd << getContextAlias() << "." << "getGeomManager().importIGES(\""<<n<<"\"";
if (splitCompoundCurves)
cmd << (splitCompoundCurves?", True":", False");
cmd << ")";
cmd << getContextAlias() << "." << "getGeomManager().importIGES(\"" << n << "\")";
command->setScriptCommand(cmd);

// on passe au gestionnaire de commandes qui exécute la commande en // ou non
Expand All @@ -3524,19 +3521,19 @@ Internal::M3DCommandResultIfc* GeomManager::importIGES(std::string n, const bool
return cmdResult;
}
/*----------------------------------------------------------------------------*/
Internal::M3DCommandResultIfc* GeomManager::importCATIA(std::string n, const bool testVolumicProperties, const bool splitCompoundCurves)
Internal::M3DCommandResultIfc* GeomManager::importCATIA(std::string n, const bool testVolumicProperties)
{
TkUtil::UTF8String message (TkUtil::Charset::UTF_8);
message << "GeomManager::importCATIA ("<<n<<")";
log (TkUtil::TraceLog (message, TkUtil::Log::TRACE_3));

//creation de la commande de création
CommandImportCATIA *command = new CommandImportCATIA(getLocalContext(), n, testVolumicProperties, splitCompoundCurves);
CommandImportCATIA *command = new CommandImportCATIA(getLocalContext(), n, testVolumicProperties);
// trace dans le script
TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8);
cmd << getContextAlias() << "." << "getGeomManager().importCATIA(\""<<n<<"\"";
if (!testVolumicProperties || splitCompoundCurves)
cmd << (testVolumicProperties?", True":", False") << (splitCompoundCurves?", True":", False");
if (!testVolumicProperties)
cmd << (testVolumicProperties?", True":", False");
cmd << ")";
command->setScriptCommand(cmd);

Expand Down
8 changes: 4 additions & 4 deletions src/Core/Geom/GeomManagerIfc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,17 +534,17 @@ Internal::M3DCommandResultIfc* GeomManagerIfc::sectionByPlane(std::vector<std::s
throw TkUtil::Exception (TkUtil::UTF8String ("GeomManagerIfc::section should be overloaded.", TkUtil::Charset::UTF_8));
}
/*----------------------------------------------------------------------------*/
Internal::M3DCommandResultIfc* GeomManagerIfc::importBREP(std::string n, const bool testVolumicProperties, const bool splitCompoundCurves)
Internal::M3DCommandResultIfc* GeomManagerIfc::importBREP(std::string n, const bool testVolumicProperties)
{
throw TkUtil::Exception (TkUtil::UTF8String ("GeomManagerIfc::importBREP should be overloaded.", TkUtil::Charset::UTF_8));
}
/*----------------------------------------------------------------------------*/
Internal::M3DCommandResultIfc* GeomManagerIfc::importCATIA(std::string n, const bool testVolumicProperties, const bool splitCompoundCurves)
Internal::M3DCommandResultIfc* GeomManagerIfc::importCATIA(std::string n, const bool testVolumicProperties)
{
throw TkUtil::Exception(TkUtil::UTF8String ("GeomManagerIfc::importCATIA should be overloaded.", TkUtil::Charset::UTF_8));
}
/*----------------------------------------------------------------------------*/
Internal::M3DCommandResultIfc* GeomManagerIfc::importSTEP(std::string n, const bool testVolumicProperties, const bool splitCompoundCurves)
Internal::M3DCommandResultIfc* GeomManagerIfc::importSTEP(std::string n, const bool testVolumicProperties)
{
throw TkUtil::Exception (TkUtil::UTF8String ("GeomManagerIfc::importSTEP should be overloaded.", TkUtil::Charset::UTF_8));
}
Expand All @@ -554,7 +554,7 @@ Internal::M3DCommandResultIfc* GeomManagerIfc::importSTL(std::string n)
throw TkUtil::Exception (TkUtil::UTF8String ("GeomManagerIfc::importSTL should be overloaded.", TkUtil::Charset::UTF_8));
}
/*----------------------------------------------------------------------------*/
Internal::M3DCommandResultIfc* GeomManagerIfc::importIGES(std::string n, const bool splitCompoundCurves)
Internal::M3DCommandResultIfc* GeomManagerIfc::importIGES(std::string n)
{
throw TkUtil::Exception (TkUtil::UTF8String ("GeomManagerIfc::importIGES should be overloaded.", TkUtil::Charset::UTF_8));
}
Expand Down
1 change: 0 additions & 1 deletion src/Core/Internal/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,6 @@ Utils::DisplayProperties* Context::newDisplayProperties(const Utils::Entity::obj
/*----------------------------------------------------------------------------*/
void Context::newGraphicalRepresentation (Utils::Entity& entity)
{
std::cout << "Context::newGraphicalRepresentation " << entity.getName() << std::endl;
if (!isGraphical())
return;

Expand Down
3 changes: 1 addition & 2 deletions src/Core/protected/Geom/CommandImportBREP.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class CommandImportBREP: public CommandCreateGeom{
* \param c le contexte
* \param n le nom du fichier à importer
* \param testVolumicProperties s'il est nécessaire que les volumes sont fermés
* \param splitCompoundCurves décompose les courbes composites en de multiples courbes
*/
CommandImportBREP(Internal::Context& c, const std::string& n, const bool testVolumicProperties, const bool splitCompoundCurves);
CommandImportBREP(Internal::Context& c, const std::string& n, const bool testVolumicProperties);

/*------------------------------------------------------------------------*/
/** \brief Destructeur
Expand Down
3 changes: 1 addition & 2 deletions src/Core/protected/Geom/CommandImportCATIA.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ class CommandImportCATIA: public CommandCreateGeom{
* \param c le contexte
* \param n le nom du fichier à importer
* \param testVolumicProperties s'il est nécessaire que les volumes sont fermés
* \param splitCompoundCurves décompose les courbes composites en de multiples courbes
*/
CommandImportCATIA(Internal::Context& c, const std::string& n, const bool testVolumicProperties, const bool splitCompoundCurves);
CommandImportCATIA(Internal::Context& c, const std::string& n, const bool testVolumicProperties);

/*------------------------------------------------------------------------*/
/** \brief Destructeur
Expand Down
3 changes: 1 addition & 2 deletions src/Core/protected/Geom/CommandImportIGES.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ class CommandImportIGES: public CommandCreateGeom{
*
* \param c le contexte
* \param n le nom du fichier à importer
* \param splitCompoundCurves décompose les courbes composites en de multiples courbes
*/
CommandImportIGES(Internal::Context& c, const std::string& n, const bool splitCompoundCurves);
CommandImportIGES(Internal::Context& c, const std::string& n);

/*------------------------------------------------------------------------*/
/** \brief Destructeur
Expand Down
3 changes: 1 addition & 2 deletions src/Core/protected/Geom/CommandImportSTEP.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ class CommandImportSTEP: public CommandCreateGeom{
* \param c le contexte
* \param n le nom du fichier à importer
* \param testVolumicProperties s'il est nécessaire que les volumes sont fermés
* \param splitCompoundCurves décompose les courbes composites en de multiples courbes
*/
CommandImportSTEP(Internal::Context& c, const std::string& n, const bool testVolumicProperties, const bool splitCompoundCurves);
CommandImportSTEP(Internal::Context& c, const std::string& n, const bool testVolumicProperties);

/*------------------------------------------------------------------------*/
/** \brief Destructeur
Expand Down
1 change: 0 additions & 1 deletion src/Core/protected/Geom/EntityFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ class EntityFactory
/** \brief
*/
Curve* newOCCCurve(TopoDS_Edge& e);
Curve* newOCCCurve(TopoDS_Wire& w);

Curve* newOCCCompositeCurve(std::vector<TopoDS_Edge>& v_ds_edge,
Utils::Math::Point& extremaFirst, Utils::Math::Point& extremaLast);
Expand Down
7 changes: 0 additions & 7 deletions src/Core/protected/Geom/GeomImport.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ class GeomImport: public GeomModificationBaseClass {
*/
void prePerform(){};

/** active ou non la décompostion des courbes */
void setSplitCompoundCurves(bool flag)
{ m_splitCompondCurves = flag; }

/** active ou non le test comme quoi les volumes sont fermés */
void setTestVolumicProperties(bool flag)
{ m_testVolumicProperties = flag; }
Expand Down Expand Up @@ -147,9 +143,6 @@ class GeomImport: public GeomModificationBaseClass {

/// flag suivant qu'il est nécessaire ou non de tester que les volumes sont fermés
bool m_testVolumicProperties;

/// flag suivant que l'on souhaite décomposer les courbes composées en de multiples courbes
bool m_splitCompondCurves;
};
/*----------------------------------------------------------------------------*/
} // end namespace Geom
Expand Down
Loading

0 comments on commit 48a04f0

Please sign in to comment.