From: vsr Date: Fri, 11 Mar 2016 09:03:17 +0000 (+0300) Subject: 0023252: [CEA 1780] GEOM : Error on "make test" when SAMPLES module is missing X-Git-Tag: V7_8_0a2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45914b2b1521ad481380f9ae99152b7d9fff52db;p=modules%2Fgeom.git 0023252: [CEA 1780] GEOM : Error on "make test" when SAMPLES module is missing --- diff --git a/doc/salome/examples/free_boundaries.py b/doc/salome/examples/free_boundaries.py index d36bbbbf7..8fe0d475b 100644 --- a/doc/salome/examples/free_boundaries.py +++ b/doc/salome/examples/free_boundaries.py @@ -1,82 +1,35 @@ # Check Free Boundaries -import os import salome salome.salome_init() -import GEOM from salome.geom import geomBuilder geompy = geomBuilder.New(salome.myStudy) -gg = salome.ImportComponentGUI("GEOM") -# create boxes -box1 = geompy.MakeBox(0,0,0,100,50,100) -box2 = geompy.MakeBox(100,0,0,250,50,100) - -# make a compound -compound = geompy.MakeCompound([box1, box2]) - -# import from *.brep -ImportFromBREP = geompy.ImportBREP(os.getenv("DATA_DIR")+"/Shapes/Brep/flight_solid.brep") - -# get a face -faces = geompy.SubShapeAllSortedCentres(ImportFromBREP, geompy.ShapeType["FACE"]) - -# get the free boundary for face 32 -Res = geompy.GetFreeBoundary(faces[32]) -isSuccess = Res[0] -ClosedWires = Res[1] -OpenWires = Res[2] - -if isSuccess == 1 : - print "Checking free boudaries is OK." -else : - print "Checking free boudaries is KO!" -print "len(ClosedWires) = ", len(ClosedWires) - -i = 0 -for wire in ClosedWires : - wire_name = "Face 32 -> Close wires : WIRE %d"%(i+1) - geompy.addToStudy(ClosedWires[i], wire_name) - if i < len(ClosedWires) : - i = i+ 1 - -print "len(OpenWires) = ", len(OpenWires) - -i = 0 -for wire in OpenWires : - wire_name = "Face 32 -> Open wires : WIRE %d"%(i+1) - geompy.addToStudy(OpenWires[i], wire_name) - if i < len(OpenWires) : - i = i+ 1 - -# get the free boundary for face 41 -Res = geompy.GetFreeBoundary(faces[41]) -isSuccess = Res[0] -ClosedWires = Res[1] -OpenWires = Res[2] - -if isSuccess == 1 : - print "Checking free boudaries is OK." -else : - print "Checking free boudaries is KO!" -print "len(ClosedWires) = ", len(ClosedWires) - -i = 0 -for wire in ClosedWires : - wire_name = "Face 41 -> Close wires : WIRE %d"%(i+1) - geompy.addToStudy(ClosedWires[i], wire_name) - if i < len(ClosedWires) : - i = i+ 1 - -print "len(OpenWires) = ", len(OpenWires) - -i = 0 -for wire in OpenWires : - wire_name = "Face 41 -> Open wires : WIRE %d"%(i+1) - geompy.addToStudy(OpenWires[i], wire_name) - if i < len(OpenWires) : - i = i+ 1 - -# add the imported object to the study -id_ImportFromBREP = geompy.addToStudy(ImportFromBREP, "ImportFromBREP") -salome.sg.updateObjBrowser(1) +# create a shape +box1 = geompy.MakeBox(0, 0, 0, 100, 100, 100) +box2 = geompy.MakeBox(20, 20, -20, 80, 80, 120) +cut = geompy.MakeCut(box1, box2) +sid = geompy.addToStudy(cut, "Shape") + +# get all faces +faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"]) + +# for each face, get free boundaries +for fi in range(len(faces)): + fid = geompy.addToStudyInFather(cut, faces[fi], "Face %d" % (fi+1)) + isSuccess, closedWires, openWires = geompy.GetFreeBoundary(faces[fi]) + if isSuccess: + print "Check free boudaries in face %d: OK" % (fi+1) + print "-- Nb of closed boundaries = %d" % len(closedWires) + for wi in range(len(closedWires)): + wid = geompy.addToStudyInFather(faces[fi], closedWires[wi], "Closed wire %d" % (wi+1)) + pass + print "-- Nb of open boundaries = %d" % len(openWires) + for wi in range(len(openWires)): + wid = geompy.addToStudyInFather(faces[fi], openWires[wi], "Open wire %d" % (wi+1)) + pass + pass + else: + print "Check free boudaries in face %d: KO" % (fi+1) + pass + pass diff --git a/doc/salome/examples/import_export.py b/doc/salome/examples/import_export.py index 3b5f7df60..e7ed69c37 100644 --- a/doc/salome/examples/import_export.py +++ b/doc/salome/examples/import_export.py @@ -6,38 +6,65 @@ import GEOM from salome.geom import geomBuilder geompy = geomBuilder.New(salome.myStudy) -# Example of import from IGES using various formats - -# get a path to SAMPLES_SRC -import os -thePath = os.getenv("DATA_DIR") -# create filenames -theFileName1 = thePath + "/Shapes/Iges/boite-3Dipsos_m.igs" -theFileName2 = thePath + "/Shapes/Iges/boite-3Dipsos_mm.igs" -#print "thePath = ", thePath - -# get units from files -UnitName1 = geompy.GetIGESUnit(theFileName1) -UnitName2 = geompy.GetIGESUnit(theFileName2) -print "UnitName1 = ", UnitName1 -print "UnitName2 = ", UnitName2 - -# import shapes -Shape1 = geompy.ImportIGES(theFileName1) -Shape2 = geompy.ImportIGES(theFileName2) -Shape3 = geompy.ImportIGES(theFileName2, True) -[Xmin1,Xmax1, Ymin1,Ymax1, Zmin1,Zmax1] = geompy.BoundingBox(Shape1) -[Xmin2,Xmax2, Ymin2,Ymax2, Zmin2,Zmax2] = geompy.BoundingBox(Shape2) -[Xmin3,Xmax3, Ymin3,Ymax3, Zmin3,Zmax3] = geompy.BoundingBox(Shape3) -geompy.addToStudy(Shape1, "3Dipsos_m") -geompy.addToStudy(Shape2, "3Dipsos_mm") -geompy.addToStudy(Shape3, "3Dipsos_mm_scaled") -d1 = (Xmax1-Xmin1)*(Xmax1-Xmin1) + (Ymax1-Ymin1)*(Ymax1-Ymin1) + (Zmax1-Zmin1)*(Zmax1-Zmin1) -d2 = (Xmax2-Xmin2)*(Xmax2-Xmin2) + (Ymax2-Ymin2)*(Ymax2-Ymin2) + (Zmax2-Zmin2)*(Zmax2-Zmin2) -d3 = (Xmax3-Xmin3)*(Xmax3-Xmin3) + (Ymax3-Ymin3)*(Ymax3-Ymin3) + (Zmax3-Zmin3)*(Zmax3-Zmin3) -import math -dd32 = math.sqrt(d3/d2) -dd12 = math.sqrt(d1/d2) -dd31 = math.sqrt(d3/d1) -# values dd31, dd12 and dd31 can be using for checking -print "dd32 = ",dd32," dd12 = ",dd12," dd31 = ",dd31 +import tempfile, os + +# create a sphere +sphere = geompy.MakeSphereR(100) + +tmpdir = tempfile.mkdtemp() + +# export sphere to the BREP file +f_brep = os.path.join(tmpdir, "sphere.brep") +geompy.ExportBREP(sphere, f_brep) + +# export sphere to the IGES v5.3 file +f_iges = os.path.join(tmpdir, "sphere.iges") +geompy.ExportIGES(sphere, f_iges, "5.3") + +# export sphere to the STEP file, using millimeters as length units +f_step = os.path.join(tmpdir, "sphere.step") +geompy.ExportSTEP(sphere, f_step, GEOM.LU_MILLIMETER) + +# export sphere to the binary STL file, with default deflection coefficient +f_stl1 = os.path.join(tmpdir, "sphere1.stl") +geompy.ExportSTL(sphere, f_stl1, False) + +# export sphere to the ASCII STL file, with custom deflection coefficient +f_stl2 = os.path.join(tmpdir, "sphere2.stl") +geompy.ExportSTL(sphere, f_stl2, True, 0.1) + +# export sphere to the VTK file, with default deflection coefficient +f_vtk1 = os.path.join(tmpdir, "sphere1.vtk") +geompy.ExportVTK(sphere, f_vtk1) + +# export sphere to the VTK file, with custom deflection coefficient +f_vtk2 = os.path.join(tmpdir, "sphere2.vtk") +geompy.ExportVTK(sphere, f_vtk2, 0.1) + +# export sphere to the XAO file +f_xao = os.path.join(tmpdir, "sphere.xao") +geompy.ExportXAO(sphere, [], [], "author", f_xao) + +# import BREP file +sphere_brep = geompy.ImportBREP(f_brep) + +# import IGES file +sphere_iges = geompy.ImportIGES(f_iges) + +# import STEP file, taking units into account +sphere_step1 = geompy.ImportSTEP(f_step) + +# import STEP file, ignoring units (result is scaled) +sphere_step2 = geompy.ImportSTEP(f_step, True) + +# import STL files +sphere_stl1 = geompy.ImportSTL(f_stl1) +sphere_stl2 = geompy.ImportSTL(f_stl2) + +# import XAO file +ok, sphere_xao, sub_shapes, groups, fields = geompy.ImportXAO(f_xao) + +# clean up +for f in f_brep, f_iges, f_step, f_stl1, f_stl2, f_vtk1, f_vtk2, f_xao: + os.remove(f) +os.rmdir(tmpdir) diff --git a/doc/salome/examples/viewing_geom_objs_ex04.py b/doc/salome/examples/viewing_geom_objs_ex04.py index 98ef64526..093fdfbe1 100644 --- a/doc/salome/examples/viewing_geom_objs_ex04.py +++ b/doc/salome/examples/viewing_geom_objs_ex04.py @@ -7,7 +7,8 @@ import GEOM from salome.geom import geomBuilder geompy = geomBuilder.New(salome.myStudy) -texture = geompy.LoadTexture(os.getenv("DATA_DIR")+"/Textures/texture1.dat") +texture_file = os.path.join(os.getenv("GEOM_ROOT_DIR"), "share", "salome", "resources", "geom", "textures", "texture1.dat") +texture = geompy.LoadTexture(texture_file) v1 = geompy.MakeVertex(0, 0, 0) v2 = geompy.MakeVertex(100, 0, 0) diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 3d47d93ed..b08b1d5b9 100755 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -301,6 +301,13 @@ SET( _res_files ) INSTALL(FILES ${_res_files} DESTINATION ${SALOME_GEOM_INSTALL_RES_DATA}) +SET( _texture_files + texture1.dat + texture2.dat + texture3.dat +) +INSTALL(FILES ${_texture_files} DESTINATION ${SALOME_GEOM_INSTALL_RES_DATA}/textures) + SALOME_CONFIGURE_FILE(GEOMCatalog.xml.in GEOMCatalog.xml INSTALL ${SALOME_GEOM_INSTALL_RES_DATA}) SALOME_CONFIGURE_FILE(SalomeApp.xml.in SalomeApp.xml INSTALL ${SALOME_GEOM_INSTALL_RES_DATA}) SALOME_CONFIGURE_FILE(Plugin.in Plugin INSTALL ${SALOME_GEOM_INSTALL_RES_DATA}) diff --git a/resources/texture1.dat b/resources/texture1.dat new file mode 100755 index 000000000..7c37a0a53 --- /dev/null +++ b/resources/texture1.dat @@ -0,0 +1,8 @@ +11111111 +10000001 +10011001 +10111101 +10111101 +10011001 +10000001 +11111111 \ No newline at end of file diff --git a/resources/texture2.dat b/resources/texture2.dat new file mode 100755 index 000000000..43f3ea0af --- /dev/null +++ b/resources/texture2.dat @@ -0,0 +1,8 @@ +00111100 +00111100 +11111111 +11111111 +11111111 +11111111 +00111100 +00111100 \ No newline at end of file diff --git a/resources/texture3.dat b/resources/texture3.dat new file mode 100755 index 000000000..3ea373329 --- /dev/null +++ b/resources/texture3.dat @@ -0,0 +1,8 @@ +00111100 +00000000 +10111101 +10111101 +10111101 +10111101 +00000000 +00111100 \ No newline at end of file