mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-04-08 12:57:27 +05:00
0023252: [CEA 1780] GEOM : Error on "make test" when SAMPLES module is missing
This commit is contained in:
parent
1125dd9734
commit
45914b2b15
@ -1,82 +1,35 @@
|
|||||||
# Check Free Boundaries
|
# Check Free Boundaries
|
||||||
|
|
||||||
import os
|
|
||||||
import salome
|
import salome
|
||||||
salome.salome_init()
|
salome.salome_init()
|
||||||
import GEOM
|
|
||||||
from salome.geom import geomBuilder
|
from salome.geom import geomBuilder
|
||||||
geompy = geomBuilder.New(salome.myStudy)
|
geompy = geomBuilder.New(salome.myStudy)
|
||||||
gg = salome.ImportComponentGUI("GEOM")
|
|
||||||
|
|
||||||
# create boxes
|
# create a shape
|
||||||
box1 = geompy.MakeBox(0,0,0,100,50,100)
|
box1 = geompy.MakeBox(0, 0, 0, 100, 100, 100)
|
||||||
box2 = geompy.MakeBox(100,0,0,250,50,100)
|
box2 = geompy.MakeBox(20, 20, -20, 80, 80, 120)
|
||||||
|
cut = geompy.MakeCut(box1, box2)
|
||||||
|
sid = geompy.addToStudy(cut, "Shape")
|
||||||
|
|
||||||
# make a compound
|
# get all faces
|
||||||
compound = geompy.MakeCompound([box1, box2])
|
faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"])
|
||||||
|
|
||||||
# import from *.brep
|
# for each face, get free boundaries
|
||||||
ImportFromBREP = geompy.ImportBREP(os.getenv("DATA_DIR")+"/Shapes/Brep/flight_solid.brep")
|
for fi in range(len(faces)):
|
||||||
|
fid = geompy.addToStudyInFather(cut, faces[fi], "Face %d" % (fi+1))
|
||||||
# get a face
|
isSuccess, closedWires, openWires = geompy.GetFreeBoundary(faces[fi])
|
||||||
faces = geompy.SubShapeAllSortedCentres(ImportFromBREP, geompy.ShapeType["FACE"])
|
if isSuccess:
|
||||||
|
print "Check free boudaries in face %d: OK" % (fi+1)
|
||||||
# get the free boundary for face 32
|
print "-- Nb of closed boundaries = %d" % len(closedWires)
|
||||||
Res = geompy.GetFreeBoundary(faces[32])
|
for wi in range(len(closedWires)):
|
||||||
isSuccess = Res[0]
|
wid = geompy.addToStudyInFather(faces[fi], closedWires[wi], "Closed wire %d" % (wi+1))
|
||||||
ClosedWires = Res[1]
|
pass
|
||||||
OpenWires = Res[2]
|
print "-- Nb of open boundaries = %d" % len(openWires)
|
||||||
|
for wi in range(len(openWires)):
|
||||||
if isSuccess == 1 :
|
wid = geompy.addToStudyInFather(faces[fi], openWires[wi], "Open wire %d" % (wi+1))
|
||||||
print "Checking free boudaries is OK."
|
pass
|
||||||
else :
|
pass
|
||||||
print "Checking free boudaries is KO!"
|
else:
|
||||||
print "len(ClosedWires) = ", len(ClosedWires)
|
print "Check free boudaries in face %d: KO" % (fi+1)
|
||||||
|
pass
|
||||||
i = 0
|
pass
|
||||||
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)
|
|
||||||
|
@ -6,38 +6,65 @@ import GEOM
|
|||||||
from salome.geom import geomBuilder
|
from salome.geom import geomBuilder
|
||||||
geompy = geomBuilder.New(salome.myStudy)
|
geompy = geomBuilder.New(salome.myStudy)
|
||||||
|
|
||||||
# Example of import from IGES using various formats
|
import tempfile, os
|
||||||
|
|
||||||
# get a path to SAMPLES_SRC
|
# create a sphere
|
||||||
import os
|
sphere = geompy.MakeSphereR(100)
|
||||||
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
|
tmpdir = tempfile.mkdtemp()
|
||||||
UnitName1 = geompy.GetIGESUnit(theFileName1)
|
|
||||||
UnitName2 = geompy.GetIGESUnit(theFileName2)
|
|
||||||
print "UnitName1 = ", UnitName1
|
|
||||||
print "UnitName2 = ", UnitName2
|
|
||||||
|
|
||||||
# import shapes
|
# export sphere to the BREP file
|
||||||
Shape1 = geompy.ImportIGES(theFileName1)
|
f_brep = os.path.join(tmpdir, "sphere.brep")
|
||||||
Shape2 = geompy.ImportIGES(theFileName2)
|
geompy.ExportBREP(sphere, f_brep)
|
||||||
Shape3 = geompy.ImportIGES(theFileName2, True)
|
|
||||||
[Xmin1,Xmax1, Ymin1,Ymax1, Zmin1,Zmax1] = geompy.BoundingBox(Shape1)
|
# export sphere to the IGES v5.3 file
|
||||||
[Xmin2,Xmax2, Ymin2,Ymax2, Zmin2,Zmax2] = geompy.BoundingBox(Shape2)
|
f_iges = os.path.join(tmpdir, "sphere.iges")
|
||||||
[Xmin3,Xmax3, Ymin3,Ymax3, Zmin3,Zmax3] = geompy.BoundingBox(Shape3)
|
geompy.ExportIGES(sphere, f_iges, "5.3")
|
||||||
geompy.addToStudy(Shape1, "3Dipsos_m")
|
|
||||||
geompy.addToStudy(Shape2, "3Dipsos_mm")
|
# export sphere to the STEP file, using millimeters as length units
|
||||||
geompy.addToStudy(Shape3, "3Dipsos_mm_scaled")
|
f_step = os.path.join(tmpdir, "sphere.step")
|
||||||
d1 = (Xmax1-Xmin1)*(Xmax1-Xmin1) + (Ymax1-Ymin1)*(Ymax1-Ymin1) + (Zmax1-Zmin1)*(Zmax1-Zmin1)
|
geompy.ExportSTEP(sphere, f_step, GEOM.LU_MILLIMETER)
|
||||||
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)
|
# export sphere to the binary STL file, with default deflection coefficient
|
||||||
import math
|
f_stl1 = os.path.join(tmpdir, "sphere1.stl")
|
||||||
dd32 = math.sqrt(d3/d2)
|
geompy.ExportSTL(sphere, f_stl1, False)
|
||||||
dd12 = math.sqrt(d1/d2)
|
|
||||||
dd31 = math.sqrt(d3/d1)
|
# export sphere to the ASCII STL file, with custom deflection coefficient
|
||||||
# values dd31, dd12 and dd31 can be using for checking
|
f_stl2 = os.path.join(tmpdir, "sphere2.stl")
|
||||||
print "dd32 = ",dd32," dd12 = ",dd12," dd31 = ",dd31
|
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)
|
||||||
|
@ -7,7 +7,8 @@ import GEOM
|
|||||||
from salome.geom import geomBuilder
|
from salome.geom import geomBuilder
|
||||||
geompy = geomBuilder.New(salome.myStudy)
|
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)
|
v1 = geompy.MakeVertex(0, 0, 0)
|
||||||
v2 = geompy.MakeVertex(100, 0, 0)
|
v2 = geompy.MakeVertex(100, 0, 0)
|
||||||
|
@ -301,6 +301,13 @@ SET( _res_files
|
|||||||
)
|
)
|
||||||
INSTALL(FILES ${_res_files} DESTINATION ${SALOME_GEOM_INSTALL_RES_DATA})
|
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(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(SalomeApp.xml.in SalomeApp.xml INSTALL ${SALOME_GEOM_INSTALL_RES_DATA})
|
||||||
SALOME_CONFIGURE_FILE(Plugin.in Plugin INSTALL ${SALOME_GEOM_INSTALL_RES_DATA})
|
SALOME_CONFIGURE_FILE(Plugin.in Plugin INSTALL ${SALOME_GEOM_INSTALL_RES_DATA})
|
||||||
|
8
resources/texture1.dat
Executable file
8
resources/texture1.dat
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
11111111
|
||||||
|
10000001
|
||||||
|
10011001
|
||||||
|
10111101
|
||||||
|
10111101
|
||||||
|
10011001
|
||||||
|
10000001
|
||||||
|
11111111
|
8
resources/texture2.dat
Executable file
8
resources/texture2.dat
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
00111100
|
||||||
|
00111100
|
||||||
|
11111111
|
||||||
|
11111111
|
||||||
|
11111111
|
||||||
|
11111111
|
||||||
|
00111100
|
||||||
|
00111100
|
8
resources/texture3.dat
Executable file
8
resources/texture3.dat
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
00111100
|
||||||
|
00000000
|
||||||
|
10111101
|
||||||
|
10111101
|
||||||
|
10111101
|
||||||
|
10111101
|
||||||
|
00000000
|
||||||
|
00111100
|
Loading…
x
Reference in New Issue
Block a user