0023252: [CEA 1780] GEOM : Error on "make test" when SAMPLES module is missing

This commit is contained in:
vsr 2016-03-11 12:03:17 +03:00
parent 1125dd9734
commit 45914b2b15
7 changed files with 118 additions and 106 deletions

View File

@ -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)
# 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")
# make a compound
compound = geompy.MakeCompound([box1, box2])
# get all faces
faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"])
# 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)
# 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

View File

@ -6,38 +6,65 @@ import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
# Example of import from IGES using various formats
import tempfile, os
# 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
# create a sphere
sphere = geompy.MakeSphereR(100)
# get units from files
UnitName1 = geompy.GetIGESUnit(theFileName1)
UnitName2 = geompy.GetIGESUnit(theFileName2)
print "UnitName1 = ", UnitName1
print "UnitName2 = ", UnitName2
tmpdir = tempfile.mkdtemp()
# 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
# 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)

View File

@ -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)

View File

@ -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})

8
resources/texture1.dat Executable file
View File

@ -0,0 +1,8 @@
11111111
10000001
10011001
10111101
10111101
10011001
10000001
11111111

8
resources/texture2.dat Executable file
View File

@ -0,0 +1,8 @@
00111100
00111100
11111111
11111111
11111111
11111111
00111100
00111100

8
resources/texture3.dat Executable file
View File

@ -0,0 +1,8 @@
00111100
00000000
10111101
10111101
10111101
10111101
00000000
00111100