Skip to content

Commit a6d078c

Browse files
Fix regresion wrt #194 (#227)
* Regression fix + dead conf removal * Copy/paste error fix * Test for the regression fix --------- Co-authored-by: adam-urbanczyk <13981538+adam-urbanczyk@users.noreply.github.com>
1 parent b0495a7 commit a6d078c

3 files changed

Lines changed: 122 additions & 61 deletions

File tree

‎conda/meta.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% set OCCT_VER = "8.0.1" %}
2-
{% set OCP_TWEAK = "0" %}
2+
{% set OCP_TWEAK = "1" %}
33

44
package:
55
name: ocp

‎ocp.toml‎

Lines changed: 34 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ class Adaptor3d_Surface;
14491449

14501450
[Attributes]
14511451

1452-
__version__ = "8.0.1.0"
1452+
__version__ = "8.0.1.1"
14531453

14541454
[Modules]
14551455

@@ -1534,10 +1534,6 @@ void register_template_NCollection_Vector(py::object &m, const char *name){
15341534
exclude_functions = ["OSD","OSD_OpenStream"]
15351535
exclude_classes = ["OSD","OSD_FileSystem","OSD_CachedFileSystem","OSD_FileSystemSelector","OSD_LocalFileSystem"]
15361536
exclude_methods = ["OSD_SharedLibrary::DlSymb"]
1537-
#"OSD_FileSystem::IsOpenIStream","OSD_FileSystem::IsOpenOStream","OSD_FileSystem::OpenOStream","OSD_FileSystem::OpenIStream",
1538-
#"OSD_CachedFileSystem::IsOpenIStream","OSD_CachedFileSystem::IsOpenOStream","OSD_CachedFileSystem::OpenOStream","OSD_CachedFileSystem::OpenIStream",
1539-
#"OSD_FileSystemSelector::IsOpenIStream","OSD_FileSystemSelector::IsOpenOStream","OSD_FileSystemSelector::OpenOStream","OSD_FileSystemSelector::OpenIStream",
1540-
#"OSD_LocalFileSystem::IsOpenIStream","OSD_LocalFileSystem::IsOpenOStream","OSD_LocalFileSystem::OpenOStream","OSD_LocalFileSystem::OpenIStream"]
15411537

15421538
include_body_pre = 'py::class_<OSD_FileSystem, opencascade::handle<OSD_FileSystem>>(m, "OSD_FileSystem");'
15431539

@@ -1561,11 +1557,25 @@ void register_template_NCollection_Vector(py::object &m, const char *name){
15611557
"TCollection_ExtendedString::operator\\+=",
15621558
"TCollection_ExtendedString::AssignCat",
15631559
]
1560+
include_body_post = """py::implicitly_convertible<std::string, TCollection_HAsciiString>();
1561+
py::implicitly_convertible<std::string, TCollection_AsciiString>();"""
15641562

15651563
[Modules.TCollection.Classes.TCollection_ExtendedString]
15661564

15671565
exclude_constructors = ["string_view"]
15681566

1567+
[[Modules.TCollection.Classes.TCollection_HAsciiString.additional_constructors]]
1568+
1569+
body = "[](const std::string &s){ return TCollection_HAsciiString(s.c_str()); }"
1570+
help = "std::strings based constructor"
1571+
arguments = ["aString"]
1572+
1573+
[[Modules.TCollection.Classes.TCollection_AsciiString.additional_constructors]]
1574+
1575+
body = "[](const std::string &s){ return TCollection_AsciiString(s.c_str()); }"
1576+
help = "std::strings based constructor"
1577+
arguments = ["aString"]
1578+
15691579
[Modules.TColStd]
15701580

15711581
exclude_typedefs = ["TColStd_DataMapOfIntegerTransient","TColStd","TColStd_DataMapOfTransientTransient","TColStd_IndexedDataMapOfTransientTransient"]
@@ -1873,8 +1883,6 @@ auto OptionsForAttach = [](){return AIS_Manipulator::OptionsForAttach();};"""
18731883

18741884
exclude_typedefs = ["Select3D_IndexedMapOfEntity","Graphic3d_Vec3d","Select3D_BndBox3d"] #couldn't deduce template parameter ‘Hasher’
18751885

1876-
# exclude_methods = ["Select3D_SensitiveFace::GetPoints","Select3D_SensitivePoly::Points3D", "Select3D_InteriorSensitivePointSet::GetPoints"]
1877-
18781886
[Modules.Select3D.Classes.Select3D_SensitiveCircle]
18791887

18801888
exclude_constructors = [0,1] #missing vftable
@@ -2168,6 +2176,12 @@ struct __GLXFBConfigRec {};"""
21682176

21692177
exclude_classes = ["StepData_EnumTool"]
21702178

2179+
[Modules.StepData.Classes.StepData_SelectType.additional_methods.SetValue]
2180+
2181+
body = "[](StepData_SelectType &self , py::object& ent){self.SetValue(cast_pyobject<Standard_Transient>(ent));}"
2182+
help = "SetValue supporting python objects"
2183+
arguments = ["ent"]
2184+
21712185
[Modules.LDOM]
21722186

21732187
exclude_classes = ["LDOMString","LDOM_MemManager","LDOM_BasicText"]
@@ -2185,7 +2199,6 @@ struct __GLXFBConfigRec {};"""
21852199
[Modules.ShapeAnalysis]
21862200

21872201
exclude_classes = ["ShapeAnalysis_BoxBndTreeSelector"]
2188-
# exlcude_methods = ["ShapeAnalysis_FreeBounds::ConnectEdgesToWires", "ShapeAnalysis_FreeBounds::ConnectWiresToWires","ShapeAnalysis_FreeBounds::SplitWires"]
21892202

21902203
[Modules.V3d]
21912204

@@ -2346,12 +2359,22 @@ using rapidjson::BasicOStreamWrapper;"""
23462359

23472360
[Modules.Interface]
23482361

2349-
# exclude_methods = ["Interface_IntList::Internals", "Interface_STAT::Internals"]
2350-
23512362
[Modules.Interface.parsing_headers]
23522363

23532364
"Interface_ValueInterpret.hxx" = "#include <Interface_TypedValue.hxx>"
23542365

2366+
[Modules.Interface.Classes.Interface_InterfaceModel.additional_methods.AddEntity]
2367+
2368+
body = "[](Interface_InterfaceModel &self , py::object& ent){self.AddEntity(cast_pyobject<Standard_Transient>(ent));}"
2369+
help = "AddEntity supporting python objects"
2370+
arguments = ["anEnt"]
2371+
2372+
[Modules.Interface.Classes.Interface_InterfaceModel.additional_methods.AddWithRefs]
2373+
2374+
body = "[](Interface_InterfaceModel &self , py::object& ent){self.AddWithRefs(cast_pyobject<Standard_Transient>(ent));}"
2375+
help = "AddWithRefs supporting python objects"
2376+
arguments = ["anEnt"]
2377+
23552378
[Modules.IVtkVTK]
23562379

23572380
include_header_pre = """#include <vtkRenderer.h>
@@ -2449,8 +2472,6 @@ using rapidjson::BasicOStreamWrapper;"""
24492472

24502473
[Modules.IGESGeom]
24512474

2452-
# exclude_methods = ["IGESGeom_SplineSurface::Polynomials"]
2453-
24542475
module_parsing_header = "#include <Standard_OStream.hxx>"
24552476

24562477
[Modules.IGESGraph]
@@ -2463,8 +2484,6 @@ using rapidjson::BasicOStreamWrapper;"""
24632484

24642485
[Modules.GeomConvert]
24652486

2466-
# exclude_methods = ["GeomConvert::ConcatG1","GeomConvert::ConcatC1","GeomConvert::C0BSplineToC1BSplineCurve","GeomConvert::C0BSplineToArrayOfC1BSplineCurve",]
2467-
24682487
[Modules.GeomConvert.parsing_headers]
24692488

24702489
"GeomConvert_SurfToAnaSurf.hxx" = "class Geom_Curve; class gp_Ax3;"
@@ -2568,52 +2587,7 @@ using rapidjson::BasicOStreamWrapper;"""
25682587
[Modules.StepAP214]
25692588

25702589
include_header_pre = "#include <Interface_InterfaceModel.hxx>"
2571-
#
2572-
# [Modules.AppDef]
2573-
#
2574-
# exclude_methods = ["AppDef_SmoothCriterion::GetCurve","AppDef_LinearCriteria::GetCurve"]
2575-
#
2576-
# [Modules.BRepGProp]
2577-
#
2578-
# exclude_methods = ["BRepGProp_Face::GetUKnots", "BRepGProp_Face::GetTKnots", "BRepG_MeshCinert::PreparePolygon"]
2579-
#
2580-
# # [Modules.BSplCLib]
2581-
# #
2582-
# # exclude_methods =["BSplCLib::MergeBSplineKnots"]
2583-
#
2584-
# [Modules.Convert]
2585-
#
2586-
# exclude_methods = [
2587-
# "Convert_CompPolynomialToPoles::Poles","Convert_CompPolynomialToPoles::Knots","Convert_CompPolynomialToPoles::Multiplicities",
2588-
# "Convert_ConicToBSplineCurve::BuildCosAndSin"
2589-
# ]
2590-
#
2591-
# [Modules.FEmTool]
2592-
#
2593-
# exclude_methods = ["FEmTool_Assembly::GetAssemblyTable"]
2594-
#
2595-
# [Modules.Geom2dConvert]
2596-
#
2597-
# exclude_methods = ["Geom2dConvert::ConcatG1","Geom2dConvert::ConcatC1","Geom2dConvert::C0BSplineToC1BSplineCurve","Geom2dConvert::C0BSplineToArrayOfC1BSplineCurve",]
2598-
#
2599-
# [Modules.GeomLib]
2600-
#
2601-
# exclude_methods = ["GeomLib::RemovePointsFromArray", "GeomLib::DensifyArray1OfReal"]
2602-
#
2603-
# [Modules.IntCurveSurface]
2604-
#
2605-
# exclude_methods = ["IntCurveSurface_TheHCurveTool::SamplePars"]
2606-
#
2607-
# [Modules.Plate]
2608-
#
2609-
# exclude_methods = ["Plate_Plate::CoefPol"]
2610-
#
2611-
#
2612-
# [Modules.ShapeExtend]
2613-
#
2614-
# exclude_methods = ["ShapeExtend::DispatchList"]
2615-
#
2616-
#
2590+
26172591
[Modules.math]
26182592

26192593
exclude_methods = ["math_Matrix::operator="] # move assignemnt operator...

‎tests/test_step.py‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
from OCP import Interface
2+
from OCP.collections import (
3+
HArray1_StepRepr_RepresentationItem as StepRepr_HArray1OfRepresentationItem,
4+
)
5+
from OCP.GeomToStep import GeomToStep_MakeAxis2Placement3d
6+
from OCP.gp import gp_Ax2, gp_Pnt
7+
from OCP.IFSelect import IFSelect_ReturnStatus
8+
from OCP.STEPCAFControl import STEPCAFControl_Writer
9+
from OCP.STEPConstruct import STEPConstruct
10+
from OCP.STEPControl import STEPControl_StepModelType
11+
from OCP.StepData import StepData_Factors
12+
13+
from OCP.StepRepr import (
14+
StepRepr_ConstructiveGeometryRepresentation,
15+
StepRepr_ConstructiveGeometryRepresentationRelationship,
16+
)
17+
from OCP.StepShape import StepShape_ShapeDefinitionRepresentation
18+
from OCP.TCollection import (
19+
TCollection_ExtendedString,
20+
TCollection_HAsciiString,
21+
)
22+
from OCP.TDocStd import TDocStd_Document
23+
from OCP.XCAFApp import XCAFApp_Application
24+
from OCP.XCAFDoc import XCAFDoc_DocumentTool
25+
from OCP.XmlXCAFDrivers import XmlXCAFDrivers
26+
from OCP.XSControl import XSControl_WorkSession
27+
28+
from OCP.BRepBuilderAPI import BRepBuilderAPI_MakeVertex
29+
30+
31+
def _step_with_supplemental_geom(path: str, loc_name: str,) -> None:
32+
33+
# create a doc and add a dummy vertex shape
34+
app = XCAFApp_Application.GetApplication_s()
35+
XmlXCAFDrivers.DefineFormat_s(app)
36+
doc = TDocStd_Document(TCollection_ExtendedString("XmlXCAF"))
37+
app.InitDocument(doc)
38+
39+
tool = XCAFDoc_DocumentTool.ShapeTool_s(doc.Main())
40+
tool.AddShape(BRepBuilderAPI_MakeVertex(gp_Pnt(0, 0, 0)).Vertex(), False, True)
41+
42+
# transfer the model to a STEP model
43+
session = XSControl_WorkSession()
44+
writer = STEPCAFControl_Writer(session, False)
45+
writer.Transfer(doc, STEPControl_StepModelType.STEPControl_AsIs)
46+
47+
model = session.Model()
48+
49+
# add a extra named location
50+
for i in range(model.NbEntities()):
51+
ent = model.Value(i + 1)
52+
53+
if isinstance(ent, StepShape_ShapeDefinitionRepresentation):
54+
sdr = ent
55+
break
56+
57+
rep = sdr.UsedRepresentation()
58+
59+
cs_array = StepRepr_HArray1OfRepresentationItem(1, 1)
60+
61+
step_loc = GeomToStep_MakeAxis2Placement3d(gp_Ax2(), StepData_Factors()).Value()
62+
step_loc.SetName(TCollection_HAsciiString(loc_name))
63+
64+
cs_array.SetValue(1, step_loc)
65+
66+
cgr = StepRepr_ConstructiveGeometryRepresentation()
67+
cgr.Init(
68+
"Additional coordinate system", cs_array, rep.ContextOfItems(),
69+
)
70+
71+
cgrr = StepRepr_ConstructiveGeometryRepresentationRelationship()
72+
cgrr.Init("", "", rep, cgr)
73+
74+
model.AddWithRefs(cgrr)
75+
76+
status = writer.Write(path)
77+
assert status == IFSelect_ReturnStatus.IFSelect_RetDone
78+
79+
80+
def test_supplemental_geom():
81+
82+
_step_with_supplemental_geom("supplemental.step", "supplemental location")
83+
84+
with open("supplemental.step") as f:
85+
step = f.read()
86+
87+
assert "supplemental location" in step

0 commit comments

Comments
 (0)