Skip to content

Commit 3e6a900

Browse files
committed
OCC: removeFaces in OCAF
1 parent 7e8a10f commit 3e6a900

File tree

10 files changed

+50
-98
lines changed

10 files changed

+50
-98
lines changed

Cassiopee/OCC/OCC/Atomic/addFillet.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ PyObject* K_OCC::addFillet(PyObject* self, PyObject* args)
4242
if (!PYPARSETUPLE_(args, OO_ R_ OO_, &hook, &listEdges, &radius, &edgeMap, &faceMap)) return NULL;
4343

4444
GETPACKET;
45-
46-
// get top shape
47-
TopoDS_Shape* shape = (TopoDS_Shape*)packet[0];
48-
TopTools_IndexedMapOfShape& edges = *(TopTools_IndexedMapOfShape*)packet[2];
49-
TopTools_IndexedMapOfShape& surfaces = *(TopTools_IndexedMapOfShape*)packet[1];
45+
GETSHAPE;
46+
GETMAPEDGES;
47+
GETMAPSURFACES;
5048

5149
// get edges
5250
BRepFilletAPI_MakeFillet mkFillet(*shape);

Cassiopee/OCC/OCC/Atomic/getLabelName.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
//=====================================================================
3030
E_Int K_OCC::getLabelName(TDF_Label& label, TCollection_ExtendedString& labelName)
3131
{
32-
labelName = "unknown";
32+
labelName = "Unnamed";
3333
Handle(TDataStd_Name) name = new TDataStd_Name();
3434
if (label.FindAttribute(TDataStd_Name::GetID(), name))
3535
{

Cassiopee/OCC/OCC/Atomic/projectOnFace.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,8 @@ PyObject* K_OCC::projectOnFaces(PyObject* self, PyObject* args)
7474
PyObject* hook; PyObject* array; PyObject* faceList;
7575
if (!PYPARSETUPLE_(args, OOO_, &hook, &array, &faceList)) return NULL;
7676

77-
void** packet = NULL;
78-
#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 7) || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 1)
79-
packet = (void**) PyCObject_AsVoidPtr(hook);
80-
#else
81-
packet = (void**) PyCapsule_GetPointer(hook, NULL);
82-
#endif
77+
GETPACKET;
78+
GETMAPSURFACES;
8379

8480
// array a projeter
8581
FldArrayF* fi; E_Int ni, nj, nk;
@@ -92,9 +88,6 @@ PyObject* K_OCC::projectOnFaces(PyObject* self, PyObject* args)
9288
return NULL;
9389
}
9490

95-
TopTools_IndexedMapOfShape& surfaces = *(TopTools_IndexedMapOfShape*)packet[1];
96-
//TopTools_IndexedMapOfShape& edges = *(TopTools_IndexedMapOfShape*)packet[2];
97-
9891
// liste des no des faces sur lesquelles on projete
9992
FldArrayI faces;
10093
if (faceList == Py_None)

Cassiopee/OCC/OCC/Atomic/readCAD.cpp

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,8 @@ PyObject* K_OCC::getNbFaces(PyObject* self, PyObject* args)
190190
PyObject* hook;
191191
if (!PYPARSETUPLE_(args, O_, &hook)) return NULL;
192192

193-
void** packet = NULL;
194-
#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 7) || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 1)
195-
packet = (void**) PyCObject_AsVoidPtr(hook);
196-
#else
197-
packet = (void**) PyCapsule_GetPointer(hook, NULL);
198-
#endif
199-
200-
TopTools_IndexedMapOfShape& surfaces = *(TopTools_IndexedMapOfShape*)packet[1];
193+
GETPACKET;
194+
GETMAPSURFACES;
201195
return Py_BuildValue("l", surfaces.Extent());
202196
}
203197

@@ -209,14 +203,8 @@ PyObject* K_OCC::getNbEdges(PyObject* self, PyObject* args)
209203
PyObject* hook;
210204
if (!PYPARSETUPLE_(args, O_, &hook)) return NULL;
211205

212-
void** packet = NULL;
213-
#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 7) || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 1)
214-
packet = (void**) PyCObject_AsVoidPtr(hook);
215-
#else
216-
packet = (void**) PyCapsule_GetPointer(hook, NULL);
217-
#endif
218-
219-
TopTools_IndexedMapOfShape& edges = *(TopTools_IndexedMapOfShape*)packet[2];
206+
GETPACKET;
207+
GETMAPEDGES;
220208
return Py_BuildValue("l", edges.Extent());
221209
}
222210

@@ -228,12 +216,6 @@ PyObject* K_OCC::getFileAndFormat(PyObject* self, PyObject* args)
228216
PyObject* hook;
229217
if (!PYPARSETUPLE_(args, O_, &hook)) return NULL;
230218

231-
void** packet = NULL;
232-
#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 7) || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 1)
233-
packet = (void**) PyCObject_AsVoidPtr(hook);
234-
#else
235-
packet = (void**) PyCapsule_GetPointer(hook, NULL);
236-
#endif
237-
219+
GETPACKET;
238220
return Py_BuildValue("ss", packet[3], packet[4]);
239221
}

Cassiopee/OCC/OCC/Atomic/removeFaces.cpp

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,37 @@ PyObject* K_OCC::removeFaces(PyObject* self, PyObject* args)
9797
if (!PYPARSETUPLE_(args, OO_ OO_, &hook, &listFaces, &edgeMap, &faceMap)) return NULL;
9898

9999
GETPACKET;
100-
101-
// get top shape
102-
TopoDS_Shape* shp = (TopoDS_Shape*)packet[0];
103-
TopTools_IndexedMapOfShape& edges = *(TopTools_IndexedMapOfShape*)packet[2];
104-
TopTools_IndexedMapOfShape& surfaces = *(TopTools_IndexedMapOfShape*)packet[1];
105-
E_Int nbFaces = surfaces.Extent();
100+
GETSHAPE;
101+
102+
#ifdef USEXCAF
103+
GETDOC;
104+
std::map< E_Int, std::vector<E_Int> > label2Faces;
105+
std::map< E_Int, std::vector<E_Int> > label2Edges;
106+
getLabel2Edges(*doc, label2Edges);
107+
getLabel2Faces(*doc, label2Faces);
108+
for (E_Int no = 0; no < PyList_Size(listFaces); no++)
109+
{
110+
PyObject* noFaceO = PyList_GetItem(listFaces, no);
111+
E_Int noFace = PyInt_AsLong(noFaceO);
112+
for (size_t i = 0; i < label2Faces.size(); i++)
113+
{
114+
std::vector< E_Int >& f = label2Faces[i];
115+
f.erase(std::remove(f.begin(), f.end(), noFace), f.end());
116+
}
117+
}
118+
copyTopShape2OCAF(*shape, label2Edges, label2Faces, *doc);
119+
TopoDS_Shape* newshp = copyOCAF2TopShape(*doc);
120+
delete shape;
121+
SETSHAPE(newshp);
122+
Py_INCREF(Py_None);
123+
return Py_None;
106124

107-
//Handle(TDF_Data) data = new TDF_Data();
108-
//TDF_Label label = data->Root();
109-
//TDataStd_Name::Set(label, "MyFaceTag");
110-
//TDF_Tool::AddShape(label, F);
125+
#else
126+
GETMAPEDGES;
127+
GETMAPSURFACES;
128+
129+
// get top shape
130+
E_Int nbFaces = surfaces.Extent();
111131

112132
ShapeBuild_ReShape reshaper;
113133
for (E_Int no = 0; no < PyList_Size(listFaces); no++)
@@ -122,17 +142,18 @@ PyObject* K_OCC::removeFaces(PyObject* self, PyObject* args)
122142
}
123143
else printf("Warning: removeFaces: invalid face number.\n");
124144
}
125-
TopoDS_Shape shc = reshaper.Apply(*shp);
145+
TopoDS_Shape shc = reshaper.Apply(*shape);
126146

127147
// export
128148
TopoDS_Shape* newshp = new TopoDS_Shape(shc);
149+
129150
TopTools_IndexedMapOfShape* sf = new TopTools_IndexedMapOfShape();
130151
TopExp::MapShapes(*newshp, TopAbs_FACE, *sf);
131152
TopTools_IndexedMapOfShape* se = new TopTools_IndexedMapOfShape();
132153
TopExp::MapShapes(*newshp, TopAbs_EDGE, *se);
133154
getFaceMap(surfaces, *sf, faceMap);
134155
getEdgeMap(edges, *se, edgeMap);
135-
delete shp;
156+
delete shape;
136157
TopTools_IndexedMapOfShape* ptr = (TopTools_IndexedMapOfShape*)packet[1];
137158
delete ptr;
138159
TopTools_IndexedMapOfShape* ptr2 = (TopTools_IndexedMapOfShape*)packet[2];
@@ -146,4 +167,5 @@ PyObject* K_OCC::removeFaces(PyObject* self, PyObject* args)
146167

147168
Py_INCREF(Py_None);
148169
return Py_None;
170+
#endif
149171
}

Cassiopee/OCC/srcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def getFiles(module):
103103
'OCC/Atomic/rotate.cpp',
104104

105105
'OCC/Atomic/intersectEdgeFace.cpp',
106-
'OCC/Atomic/trim.cpp',
106+
'OCC/Atomic/trimFaces.cpp',
107107
'OCC/Atomic/boolean.cpp',
108108

109109
'OCC/Atomic/getOppData.cpp',

Cassiopee/OCC/test/removeFaces.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# - removeFaces (array) -
22
import OCC
33

4-
hook = OCC.readCAD("cubeNoTrim.step", "fmt_step")
4+
hook = OCC.readCAD("cube.step")
55

6-
ret = OCC.getFaceNameInOCAF(hook)
7-
cube1 = ret[3]
8-
OCC._removeFaces(hook, cube1)
6+
#faceList = OCC.getFaceNos(hook, 'Cube')
7+
OCC._removeFaces(hook, [1,2])
98

10-
OCC.writeCAD(hook, 'out.step', 'fmt_step')
9+
OCC.writeCAD(hook, 'out.step')

Cassiopee/valid

Lines changed: 0 additions & 33 deletions
This file was deleted.

Cassiopee/validAll

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)