Skip to content

Commit d67a50f

Browse files
committed
Renamed Mesh_DataSource class name to MeshDS_DataSource
1 parent 87fa9de commit d67a50f

5 files changed

Lines changed: 42 additions & 42 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,19 +315,19 @@ if(PYTHONOCC_WRAP_VISU)
315315
swig_link_libraries(Visualization /System/Library/Frameworks/Cocoa.framework)
316316
endif(APPLE)
317317

318-
###########################
319-
# MeshDataSource addition #
320-
###########################
318+
##########################
319+
# MeshDS module addition #
320+
##########################
321321
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory src/MeshDataSource)
322-
set(FILE ${SWIG_FILES_PATH}/MeshDataSource.i)
322+
set(FILE ${SWIG_FILES_PATH}/MeshDS.i)
323323
set_source_files_properties(${FILE} PROPERTIES CPLUSPLUS ON)
324324
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/MeshDataSource)
325325
set(MESHDATASOURCE_SOURCE_FILES
326326
${FILE}
327327
${CMAKE_CURRENT_SOURCE_DIR}/src/MeshDataSource/MeshDataSource.cpp)
328328

329-
swig_add_library(MeshDataSource LANGUAGE python SOURCES ${MESHDATASOURCE_SOURCE_FILES} TYPE MODULE)
330-
swig_link_libraries(MeshDataSource ${OCE_MODEL_LIBRARIES} ${OCE_VISUALIZATION_LIBRARIES} Python3::Module)
329+
swig_add_library(MeshDS LANGUAGE python SOURCES ${MESHDATASOURCE_SOURCE_FILES} TYPE MODULE)
330+
swig_link_libraries(MeshDS ${OCE_MODEL_LIBRARIES} ${OCE_VISUALIZATION_LIBRARIES} Python3::Module)
331331

332332
endif(PYTHONOCC_WRAP_VISU)
333333

@@ -410,8 +410,8 @@ if(PYTHONOCC_WRAP_VISU)
410410
endforeach(OCE_MODULE)
411411

412412
# install MeshDataSource
413-
install(FILES ${BUILD_DIR}/MeshDataSource.py DESTINATION ${PYTHONOCC_INSTALL_DIRECTORY}/Core)
414-
install(TARGETS _MeshDataSource DESTINATION ${PYTHONOCC_INSTALL_DIRECTORY}/Core)
413+
install(FILES ${BUILD_DIR}/MeshDS.py DESTINATION ${PYTHONOCC_INSTALL_DIRECTORY}/Core)
414+
install(TARGETS _MeshDS DESTINATION ${PYTHONOCC_INSTALL_DIRECTORY}/Core)
415415
endif(PYTHONOCC_WRAP_VISU)
416416

417417
if(PYTHONOCC_WRAP_DATAEXCHANGE)

src/MeshDataSource/MeshDataSource.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
#include <TColStd_DataMapOfIntegerInteger.hxx>
99
#include <TColStd_DataMapOfIntegerReal.hxx>
1010

11-
IMPLEMENT_STANDARD_RTTIEXT(Mesh_DataSource, MeshVS_DataSource)
11+
IMPLEMENT_STANDARD_RTTIEXT(MeshDS_DataSource, MeshVS_DataSource)
1212

13-
Mesh_DataSource::Mesh_DataSource(std::vector<gp_Pnt>& CoordData, std::vector<std::vector<int>>& Ele2NodeData)
13+
MeshDS_DataSource::MeshDS_DataSource(std::vector<gp_Pnt>& CoordData, std::vector<std::vector<int>>& Ele2NodeData)
1414
{
1515
InitializeFromData(CoordData, Ele2NodeData);
1616
}
1717

18-
Mesh_DataSource::Mesh_DataSource(const Handle(Poly_Triangulation)& polyTri)
18+
MeshDS_DataSource::MeshDS_DataSource(const Handle(Poly_Triangulation)& polyTri)
1919
{
2020
// initialize arrays
2121
std::vector<gp_Pnt> CoordData;
@@ -40,7 +40,7 @@ Mesh_DataSource::Mesh_DataSource(const Handle(Poly_Triangulation)& polyTri)
4040
// Function : SetElemNormals
4141
// Purpose :
4242
//================================================================
43-
void Mesh_DataSource::SetElemNormals
43+
void MeshDS_DataSource::SetElemNormals
4444
(std::vector<gp_Vec>& ElemNormalsData)
4545
{
4646
for (size_t ElementId = 1; ElementId <= ElemNormalsData.size(); ElementId++)
@@ -55,7 +55,7 @@ void Mesh_DataSource::SetElemNormals
5555
// Function : SetNodeNormals
5656
// Purpose :
5757
//================================================================
58-
void Mesh_DataSource::SetNodeNormals
58+
void MeshDS_DataSource::SetNodeNormals
5959
(std::vector<std::vector<gp_Vec>>& NodeNormalsData)
6060
{
6161
for (size_t ElementId = 1; ElementId <= myElemNodes->NbRows(); ElementId++)
@@ -72,7 +72,7 @@ void Mesh_DataSource::SetNodeNormals
7272
// Function : GetGeom
7373
// Purpose :
7474
//================================================================
75-
Standard_Boolean Mesh_DataSource::GetGeom
75+
Standard_Boolean MeshDS_DataSource::GetGeom
7676
(const Standard_Integer ID, const Standard_Boolean IsElement,
7777
TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes,
7878
MeshVS_EntityType& Type) const
@@ -112,7 +112,7 @@ Standard_Boolean Mesh_DataSource::GetGeom
112112
// Function : GetGeomType
113113
// Purpose :
114114
//================================================================
115-
Standard_Boolean Mesh_DataSource::GetGeomType
115+
Standard_Boolean MeshDS_DataSource::GetGeomType
116116
(const Standard_Integer,
117117
const Standard_Boolean IsElement,
118118
MeshVS_EntityType& Type) const
@@ -133,7 +133,7 @@ Standard_Boolean Mesh_DataSource::GetGeomType
133133
// Function : GetAddr
134134
// Purpose :
135135
//================================================================
136-
Standard_Address Mesh_DataSource::GetAddr
136+
Standard_Address MeshDS_DataSource::GetAddr
137137
(const Standard_Integer, const Standard_Boolean) const
138138
{
139139
return NULL;
@@ -143,7 +143,7 @@ Standard_Address Mesh_DataSource::GetAddr
143143
// Function : GetNodesByElement
144144
// Purpose :
145145
//================================================================
146-
Standard_Boolean Mesh_DataSource::GetNodesByElement
146+
Standard_Boolean MeshDS_DataSource::GetNodesByElement
147147
(const Standard_Integer ID,
148148
TColStd_Array1OfInteger& theNodeIDs,
149149
Standard_Integer& theNbNodes) const
@@ -165,7 +165,7 @@ Standard_Boolean Mesh_DataSource::GetNodesByElement
165165
// Function : GetAllNodes
166166
// Purpose :
167167
//================================================================
168-
const TColStd_PackedMapOfInteger& Mesh_DataSource::GetAllNodes() const
168+
const TColStd_PackedMapOfInteger& MeshDS_DataSource::GetAllNodes() const
169169
{
170170
return myNodes;
171171
}
@@ -174,7 +174,7 @@ const TColStd_PackedMapOfInteger& Mesh_DataSource::GetAllNodes() const
174174
// Function : GetAllElements
175175
// Purpose :
176176
//================================================================
177-
const TColStd_PackedMapOfInteger& Mesh_DataSource::GetAllElements() const
177+
const TColStd_PackedMapOfInteger& MeshDS_DataSource::GetAllElements() const
178178
{
179179
return myElements;
180180
}
@@ -183,7 +183,7 @@ const TColStd_PackedMapOfInteger& Mesh_DataSource::GetAllElements() const
183183
// Function : GetNormal
184184
// Purpose :
185185
//================================================================
186-
Standard_Boolean Mesh_DataSource::GetNormal
186+
Standard_Boolean MeshDS_DataSource::GetNormal
187187
(const Standard_Integer Id, const Standard_Integer Max,
188188
Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const
189189
{
@@ -202,7 +202,7 @@ Standard_Boolean Mesh_DataSource::GetNormal
202202
// Function : GetNodeNormal
203203
// Purpose :
204204
//================================================================
205-
Standard_Boolean Mesh_DataSource::GetNodeNormal
205+
Standard_Boolean MeshDS_DataSource::GetNodeNormal
206206
(const Standard_Integer rankNode, const Standard_Integer ElementId,
207207
Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const
208208
{
@@ -221,7 +221,7 @@ Standard_Boolean Mesh_DataSource::GetNodeNormal
221221
// Function : InitializeFromData
222222
// Purpose :
223223
//================================================================
224-
void Mesh_DataSource::InitializeFromData
224+
void MeshDS_DataSource::InitializeFromData
225225
(std::vector<gp_Pnt>& CoordData, std::vector<std::vector<int>>& Ele2NodeData)
226226
{
227227
//initialize arrays

src/MeshDataSource/MeshDataSource.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#if !defined __MeshDataSource__
2-
#define __MeshDataSource__
1+
#if !defined __MeshDS_DataSource__
2+
#define __MeshDS_DataSource__
33

44

55
#include <algorithm>
@@ -23,22 +23,22 @@
2323
#include <gp_Pnt.hxx>
2424
#include <gp_Vec.hxx>
2525

26-
class Mesh_DataSource;
27-
DEFINE_STANDARD_HANDLE(Mesh_DataSource, MeshVS_DataSource)
26+
class MeshDS_DataSource;
27+
DEFINE_STANDARD_HANDLE(MeshDS_DataSource, MeshVS_DataSource)
2828

29-
class Mesh_DataSource : public MeshVS_DataSource
29+
class MeshDS_DataSource : public MeshVS_DataSource
3030
{
3131
public:
3232

3333
//! Initialize data source with vector of nodes and vector of elements (triangles or quadrangles)
3434
//! Face normals are calculated using the three first nodes of each element
3535
//! Node normals are calculated averaging the normals of the neighboring elements
36-
Mesh_DataSource(std::vector<gp_Pnt>& CoordData, std::vector<std::vector<int>>& Ele2NodeData);
36+
MeshDS_DataSource(std::vector<gp_Pnt>& CoordData, std::vector<std::vector<int>>& Ele2NodeData);
3737

3838
//! Initialize data source from STL triangulation
3939
//! Face normals are calculated using the three nodes of each element
4040
//! Node normals are calculated averaging the normals of the neighboring elements
41-
Mesh_DataSource(const Handle(Poly_Triangulation)& polyTri);
41+
MeshDS_DataSource(const Handle(Poly_Triangulation)& polyTri);
4242

4343
//! This method define the normal of the face for each element
4444
void SetElemNormals(std::vector<gp_Vec>& ElemNormalsData);
@@ -76,7 +76,7 @@ class Mesh_DataSource : public MeshVS_DataSource
7676
//! Returns false if normal isn't defined.
7777
virtual Standard_Boolean GetNodeNormal(const Standard_Integer rankNode, const Standard_Integer ElementId, Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const Standard_OVERRIDE;
7878

79-
DEFINE_STANDARD_RTTIEXT(Mesh_DataSource, MeshVS_DataSource)
79+
DEFINE_STANDARD_RTTIEXT(MeshDS_DataSource, MeshVS_DataSource)
8080

8181
protected:
8282

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
##You should have received a copy of the GNU Lesser General Public License
1717
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1818
*/
19-
%module MeshDataSource;
19+
%module MeshDS;
2020

2121
%{
2222
#ifdef WNT
@@ -76,12 +76,12 @@ from OCC.Core.Exception import *
7676
%template(vector_vector_vec) std::vector<std::vector<gp_Vec> >;
7777

7878

79-
%wrap_handle(Mesh_DataSource)
79+
%wrap_handle(MeshDS_DataSource)
8080

81-
class Mesh_DataSource : public MeshVS_DataSource {
81+
class MeshDS_DataSource : public MeshVS_DataSource {
8282
public:
83-
Mesh_DataSource(std::vector<gp_Pnt> CoordData, std::vector<std::vector<int>> Ele2NodeData);
84-
Mesh_DataSource(const opencascade::handle<Poly_Triangulation> & polyTri);
83+
MeshDS_DataSource(std::vector<gp_Pnt> CoordData, std::vector<std::vector<int>> Ele2NodeData);
84+
MeshDS_DataSource(const opencascade::handle<Poly_Triangulation> & polyTri);
8585
void SetElemNormals(std::vector<gp_Vec> ElemNormalsData);
8686
void SetNodeNormals(std::vector<std::vector<gp_Vec>> NodeNormalsData);
8787
Standard_Boolean GetGeom(Standard_Integer ID, Standard_Boolean IsElement, TColStd_Array1OfReal& Coords, Standard_Integer &OutValue, MeshVS_EntityType& Type);
@@ -94,9 +94,9 @@ class Mesh_DataSource : public MeshVS_DataSource {
9494
Standard_Boolean GetNodeNormal(Standard_Integer rankNode, Standard_Integer ElementId, Standard_Real &OutValue, Standard_Real &OutValue, Standard_Real &OutValue);
9595
};
9696

97-
%make_alias(Mesh_DataSource)
97+
%make_alias(MeshDS_DataSource)
9898

99-
%extend Mesh_DataSource {
99+
%extend MeshDS_DataSource {
100100
%pythoncode {
101101
__repr__ = _dumps_object
102102
}

test/core_meshdatasource_unittest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import unittest
2121

2222
from OCC.Core.gp import gp_Pnt, gp_Vec
23-
from OCC.Core.MeshDataSource import Mesh_DataSource
23+
from OCC.Core.MeshDS import MeshDS_DataSource
2424
from OCC.Core.RWStl import rwstl_ReadFile
2525
from OCC.Core.TColStd import TColStd_Array1OfInteger
2626

@@ -29,11 +29,11 @@
2929
class TestMeshDataSource(unittest.TestCase):
3030
def test_instantiate_from_stl_file(self):
3131
a_stl_mesh = rwstl_ReadFile(STL_BOTTLE_FILENAME)
32-
Mesh_DataSource(a_stl_mesh)
32+
MeshDS_DataSource(a_stl_mesh)
3333

3434
def test_stl_file_check_bounding_box(self):
3535
a_stl_mesh = rwstl_ReadFile(STL_BOTTLE_FILENAME)
36-
a_ds = Mesh_DataSource(a_stl_mesh)
36+
a_ds = MeshDS_DataSource(a_stl_mesh)
3737
bb = a_ds.GetBoundingBox().Get()
3838
self.assertEqual(bb, (-26.5748, 4.426, -13.6694, 26.5269, 90.2, 13.5885))
3939

@@ -42,7 +42,7 @@ def test_create_mesh_datasource(self):
4242
coord_data = [gp_Pnt(0, 0, 0), gp_Pnt(0, 1, 0), gp_Pnt(0, 1, -1), gp_Pnt(1, 0, 0), gp_Pnt(1, 1, 0)]
4343
ele2_node_data = [[0, 1, 4 , 3], [1, 2, 4]]
4444
# create data source
45-
a_data_source = Mesh_DataSource(coord_data, ele2_node_data)
45+
a_data_source = MeshDS_DataSource(coord_data, ele2_node_data)
4646
# check node ids and number of elements
4747
node_ids = TColStd_Array1OfInteger(1, 4)
4848
is_ok, nb_nodes = a_data_source.GetNodesByElement(1, node_ids)
@@ -86,7 +86,7 @@ def testset_check_normals(self):
8686
[gp_Vec(0, 0, -1), gp_Vec(0, 0, -1), gp_Vec(0, 0, -1)]]
8787
elem_normals_data = [gp_Vec(0, 0, 1), gp_Vec(0, 0, 1)]
8888
# create data source
89-
a_data_source = Mesh_DataSource(coord_data, ele2_node_data)
89+
a_data_source = MeshDS_DataSource(coord_data, ele2_node_data)
9090
# check node ids and number of elements
9191
# set and check normal of elements
9292
a_data_source.SetElemNormals(elem_normals_data)

0 commit comments

Comments
 (0)