Skip to content

Commit 07a705c

Browse files
committed
Extract split methods from Curve/Surface/Volume
1 parent 7160252 commit 07a705c

File tree

11 files changed

+432
-354
lines changed

11 files changed

+432
-354
lines changed

src/Core/Geom/CommandCreateGeom.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "Geom/Surface.h"
1919
#include "Geom/Curve.h"
2020
#include "Geom/Vertex.h"
21+
#include "Geom/GeomSplitImplementation.h"
2122
#include "Group/GroupManager.h"
2223
#include "Group/Group3D.h"
2324
#include "Group/Group2D.h"
@@ -160,7 +161,8 @@ split(Volume* v)
160161
*
161162
* On utilise l'InfoCommand pour stocker les différentes entités créées
162163
*/
163-
v->split(surfaces,curves,vertices);
164+
GeomSplitImplementation gsi(getContext());
165+
gsi.split(v, surfaces, curves, vertices);
164166

165167
store(v);
166168

@@ -190,7 +192,8 @@ split(Surface* s)
190192
*
191193
* On utilise l'InfoCommand pour stocker les différentes entités créées
192194
*/
193-
s->split(curves,vertices);
195+
GeomSplitImplementation gsi(getContext());
196+
gsi.split(s, curves,vertices);
194197

195198
store(s);
196199

@@ -216,7 +219,8 @@ split(Curve* c)
216219
*
217220
* On utilise l'InfoCommand pour stocker les différentes entités créées
218221
*/
219-
c->split(vertices);
222+
GeomSplitImplementation gsi(getContext());
223+
gsi.split(c, vertices);
220224

221225
store(c);
222226

src/Core/Geom/Curve.cpp

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include <BRepAdaptor_Curve.hxx>
4343
#include <Geom2d_Curve.hxx>
4444
#include <BRep_Builder.hxx>
45-
#include <TopExp_Explorer.hxx>
4645
#include <BRepBuilderAPI_Transform.hxx>
4746
#include <BRepBuilderAPI_MakeFace.hxx>
4847
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
@@ -873,102 +872,6 @@ void Curve::remove(Vertex* v)
873872
m_vertices.erase(it);
874873
}
875874
/*----------------------------------------------------------------------------*/
876-
void Curve::split(std::vector<Vertex* >& vert)
877-
{
878-
// identification des sommets aux extrémités (ceux vus qu'une unique fois)
879-
if (m_occ_edges.size() == 1) {
880-
/* on va explorer la courbe OCC stockée en attribut et créer les entités de
881-
* dimension directement inférieure, c'est-à-dire les sommets
882-
*/
883-
Vertex* v = 0;
884-
TopExp_Explorer e;
885-
for(e.Init(m_occ_edges[0], TopAbs_VERTEX); e.More(); e.Next())
886-
{
887-
888-
TopoDS_Vertex V = TopoDS::Vertex(e.Current());
889-
// on évite de mettre 2 fois le même sommet [EB]
890-
bool are_same = false;
891-
if (v){
892-
// 1 seule représentation pour le vertex
893-
TopoDS_Vertex Vprec = TopoDS::Vertex(v->getOCCVertex());
894-
if (Vprec.IsSame(V))
895-
are_same = true;
896-
}
897-
898-
if (!are_same){
899-
// création du nouveau sommet
900-
v = EntityFactory(getContext()).newOCCVertex(V);
901-
902-
// on crée le lien C->V
903-
this->add(v);
904-
// on crée le lien V->C
905-
v->add(this);
906-
}
907-
}
908-
909-
// on renseigne la fonction appelante
910-
vert = m_vertices;
911-
} else {
912-
//std::cout<<"Curve::split avec m_occ_edges.size() = "<<m_occ_edges.size()<<std::endl;
913-
914-
std::vector<TopoDS_Vertex> vtx;
915-
for (uint i=0; i<m_occ_edges.size(); i++){
916-
TopExp_Explorer e;
917-
for(e.Init(m_occ_edges[i], TopAbs_VERTEX); e.More(); e.Next()){
918-
TopoDS_Vertex V = TopoDS::Vertex(e.Current());
919-
vtx.push_back(V);
920-
}
921-
}
922-
//std::cout<<"vtx.size() = "<<vtx.size()<<std::endl;
923-
924-
TopoDS_Vertex Vdep;
925-
TopoDS_Vertex Vfin;
926-
927-
for (uint i=0; i<vtx.size()-1; i++){
928-
TopoDS_Vertex V1 = vtx[i];
929-
for (uint j=i+1; j<vtx.size(); j++){
930-
TopoDS_Vertex V2 = vtx[j];
931-
if ((!V1.IsNull()) && (!V2.IsNull()) && OCCHelper::areEquals(V1,V2)){
932-
vtx[i].Nullify();
933-
vtx[j].Nullify();
934-
}
935-
}
936-
} // end for i<vtx.size()
937-
938-
for (uint i=0; i<vtx.size(); i++){
939-
TopoDS_Vertex V1 = vtx[i];
940-
if (!V1.IsNull()){
941-
if (Vdep.IsNull())
942-
Vdep = V1;
943-
else if (Vfin.IsNull())
944-
Vfin = V1;
945-
else {
946-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
947-
messErr << "La courbe "<<getName()<<" est composée de plusieurs parties et on trouve plus de 2 sommets comme extrémité";
948-
throw TkUtil::Exception(messErr);
949-
}
950-
951-
}
952-
}
953-
954-
if (!Vdep.IsNull()){
955-
// création du nouveau sommet
956-
Vertex* v = EntityFactory(getContext()).newOCCVertex(Vdep);
957-
// on crée le lien C->V
958-
add(v);
959-
// on crée le lien V->C
960-
v->add(this);
961-
}
962-
963-
if (!Vfin.IsNull()){
964-
Vertex* v = EntityFactory(getContext()).newOCCVertex(Vfin);
965-
add(v);
966-
v->add(this);
967-
}
968-
969-
} // end else / if (m_occ_edges.size() == 1)
970-
}
971-
/*----------------------------------------------------------------------------*/
972875
double Curve::computeArea() const
973876
{
974877
double area = 0.0;

src/Core/Geom/GeomImport.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Geom/Volume.h"
1616
#include "Geom/EntityFactory.h"
1717
#include "Geom/OCCHelper.h"
18+
#include "Geom/GeomSplitImplementation.h"
1819

1920
#include "Group/GroupManager.h"
2021
#include "Group/Group3D.h"
@@ -223,13 +224,14 @@ void GeomImport::add(TopoDS_Shape& AShape, const std::string& AName)
223224
std::vector<Surface*> surfs;
224225
std::vector<Curve* > curvs;
225226
std::vector<Vertex* > verts;
227+
GeomSplitImplementation gsi(m_context);
226228

227229
switch(AShape.ShapeType()){
228230
case TopAbs_SOLID:
229231
{
230232
Volume* vol=EntityFactory(m_context).newOCCVolume(TopoDS::Solid(AShape));
231233
addToGroup(vol, AName);
232-
vol->split(surfs,curvs,verts);
234+
gsi.split(vol, surfs, curvs, verts);
233235
store(vol);
234236
for(unsigned int i=0;i<surfs.size();i++){
235237
store(surfs[i]);
@@ -249,7 +251,7 @@ void GeomImport::add(TopoDS_Shape& AShape, const std::string& AName)
249251
{
250252
Surface* surf=EntityFactory(m_context).newOCCSurface(TopoDS::Face(AShape));
251253
addToGroup(surf, AName);
252-
surf->split(curvs,verts);
254+
gsi.split(surf, curvs, verts);
253255
store(surf);
254256
for(unsigned int i=0;i<curvs.size();i++){
255257
store(curvs[i]);
@@ -287,7 +289,7 @@ void GeomImport::add(TopoDS_Shape& AShape, const std::string& AName)
287289
{
288290
Curve* curve=EntityFactory(m_context).newOCCCurve(TopoDS::Edge(AShape));
289291
addToGroup(curve, AName);
290-
curve->split(verts);
292+
gsi.split(curve, verts);
291293
store(curve);
292294
for(unsigned int i=0;i<verts.size();i++)
293295
store(verts[i]);
@@ -310,7 +312,7 @@ void GeomImport::add(TopoDS_Shape& AShape, const std::string& AName)
310312
{
311313
Volume* vol=EntityFactory(m_context).newOCCVolume(TopoDS::Shell(AShape));
312314
addToGroup(vol, AName);
313-
vol->split(surfs,curvs,verts);
315+
gsi.split(vol, surfs, curvs, verts);
314316
store(vol);
315317
for(unsigned int i=0;i<surfs.size();i++){
316318
store(surfs[i]);

0 commit comments

Comments
 (0)