mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
Merge branch 'occ_no_maps' into 'master'
remove all std::maps<TopoDS_Shape, *> and std::set<TopoDS_Shape> See merge request ngsolve/netgen!542
This commit is contained in:
commit
6d539e0213
@ -402,11 +402,12 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
// Philippose - 15/01/2009
|
// Philippose - 15/01/2009
|
||||||
double maxh = min2(geom.face_maxh[k-1], OCCGeometry::global_shape_properties[geom.fmap(k)].maxh);
|
auto& props = OCCGeometry::GetProperties(geom.fmap(k));
|
||||||
|
double maxh = min2(geom.face_maxh[k-1], props.maxh);
|
||||||
//double maxh = mparam.maxh;
|
//double maxh = mparam.maxh;
|
||||||
// int noldpoints = mesh->GetNP();
|
// int noldpoints = mesh->GetNP();
|
||||||
int noldsurfel = mesh.GetNSE();
|
int noldsurfel = mesh.GetNSE();
|
||||||
int layer = OCCGeometry::global_shape_properties[geom.fmap(k)].layer;
|
int layer = props.layer;
|
||||||
|
|
||||||
static Timer tsurfprop("surfprop");
|
static Timer tsurfprop("surfprop");
|
||||||
tsurfprop.Start();
|
tsurfprop.Start();
|
||||||
@ -474,8 +475,9 @@ namespace netgen
|
|||||||
int dom = 0;
|
int dom = 0;
|
||||||
for (TopExp_Explorer e(geom.GetShape(), TopAbs_SOLID); e.More(); e.Next(), dom++)
|
for (TopExp_Explorer e(geom.GetShape(), TopAbs_SOLID); e.More(); e.Next(), dom++)
|
||||||
{
|
{
|
||||||
maxhdom[dom] = min2(maxhdom[dom], OCCGeometry::global_shape_properties[e.Current()].maxh);
|
auto& props = OCCGeometry::GetProperties(e.Current());
|
||||||
maxlayer = max2(maxlayer, OCCGeometry::global_shape_properties[e.Current()].layer);
|
maxhdom[dom] = min2(maxhdom[dom], props.maxh);
|
||||||
|
maxlayer = max2(maxlayer, props.layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -518,7 +520,7 @@ namespace netgen
|
|||||||
for (int i = 1; i <= nedges && !multithread.terminate; i++)
|
for (int i = 1; i <= nedges && !multithread.terminate; i++)
|
||||||
{
|
{
|
||||||
TopoDS_Edge e = TopoDS::Edge (geom.emap(i));
|
TopoDS_Edge e = TopoDS::Edge (geom.emap(i));
|
||||||
int layer = OCCGeometry::global_shape_properties[e].layer;
|
int layer = OCCGeometry::GetProperties(e).layer;
|
||||||
multithread.percent = 100 * (i-1)/double(nedges);
|
multithread.percent = 100 * (i-1)/double(nedges);
|
||||||
if (BRep_Tool::Degenerated(e)) continue;
|
if (BRep_Tool::Degenerated(e)) continue;
|
||||||
|
|
||||||
@ -564,12 +566,12 @@ namespace netgen
|
|||||||
int face_index = geom.fmap.FindIndex(parent_face);
|
int face_index = geom.fmap.FindIndex(parent_face);
|
||||||
|
|
||||||
if(face_index >= 1) localh = min(localh,geom.face_maxh[face_index - 1]);
|
if(face_index >= 1) localh = min(localh,geom.face_maxh[face_index - 1]);
|
||||||
localh = min2(localh, OCCGeometry::global_shape_properties[parent_face].maxh);
|
localh = min2(localh, OCCGeometry::GetProperties(parent_face).maxh);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(Geom_Curve) c = BRep_Tool::Curve(e, s0, s1);
|
Handle(Geom_Curve) c = BRep_Tool::Curve(e, s0, s1);
|
||||||
|
|
||||||
localh = min2(localh, OCCGeometry::global_shape_properties[e].maxh);
|
localh = min2(localh, OCCGeometry::GetProperties(e).maxh);
|
||||||
maxedgelen = max (maxedgelen, len);
|
maxedgelen = max (maxedgelen, len);
|
||||||
minedgelen = min (minedgelen, len);
|
minedgelen = min (minedgelen, len);
|
||||||
int maxj = max((int) ceil(len/localh), 2);
|
int maxj = max((int) ceil(len/localh), 2);
|
||||||
@ -592,7 +594,7 @@ namespace netgen
|
|||||||
double maxcur = 0;
|
double maxcur = 0;
|
||||||
multithread.percent = 100 * (i-1)/double(nedges);
|
multithread.percent = 100 * (i-1)/double(nedges);
|
||||||
TopoDS_Edge edge = TopoDS::Edge (geom.emap(i));
|
TopoDS_Edge edge = TopoDS::Edge (geom.emap(i));
|
||||||
int layer = OCCGeometry::global_shape_properties[edge].layer;
|
int layer = OCCGeometry::GetProperties(edge).layer;
|
||||||
if (BRep_Tool::Degenerated(edge)) continue;
|
if (BRep_Tool::Degenerated(edge)) continue;
|
||||||
double s0, s1;
|
double s0, s1;
|
||||||
Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
|
Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
|
||||||
@ -627,7 +629,7 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
multithread.percent = 100 * (i-1)/double(nfaces);
|
multithread.percent = 100 * (i-1)/double(nfaces);
|
||||||
TopoDS_Face face = TopoDS::Face(geom.fmap(i));
|
TopoDS_Face face = TopoDS::Face(geom.fmap(i));
|
||||||
int layer = OCCGeometry::global_shape_properties[face].layer;
|
int layer = OCCGeometry::GetProperties(face).layer;
|
||||||
TopLoc_Location loc;
|
TopLoc_Location loc;
|
||||||
Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
|
Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
|
||||||
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc);
|
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc);
|
||||||
@ -693,7 +695,7 @@ namespace netgen
|
|||||||
for (int i = 1; i <= nedges && !multithread.terminate; i++)
|
for (int i = 1; i <= nedges && !multithread.terminate; i++)
|
||||||
{
|
{
|
||||||
TopoDS_Edge edge = TopoDS::Edge (geom.emap(i));
|
TopoDS_Edge edge = TopoDS::Edge (geom.emap(i));
|
||||||
int layer = OCCGeometry::global_shape_properties[edge].layer;
|
int layer = OCCGeometry::GetProperties(edge).layer;
|
||||||
if (BRep_Tool::Degenerated(edge)) continue;
|
if (BRep_Tool::Degenerated(edge)) continue;
|
||||||
|
|
||||||
double s0, s1;
|
double s0, s1;
|
||||||
|
@ -71,9 +71,11 @@ namespace netgen
|
|||||||
void LoadOCCInto(OCCGeometry* occgeo, const filesystem::path & filename);
|
void LoadOCCInto(OCCGeometry* occgeo, const filesystem::path & filename);
|
||||||
void PrintContents (OCCGeometry * geom);
|
void PrintContents (OCCGeometry * geom);
|
||||||
|
|
||||||
std::map<TopoDS_Shape, ShapeProperties> OCCGeometry::global_shape_properties;
|
TopTools_IndexedMapOfShape OCCGeometry::global_shape_property_indices;
|
||||||
std::map<TopoDS_Shape, std::vector<OCCIdentification>> OCCGeometry::identifications;
|
std::vector<ShapeProperties> OCCGeometry::global_shape_properties;
|
||||||
|
TopTools_IndexedMapOfShape OCCGeometry::global_identification_indices;
|
||||||
|
std::vector<std::vector<OCCIdentification>> OCCGeometry::global_identifications;
|
||||||
|
|
||||||
TopoDS_Shape ListOfShapes::Max(gp_Vec dir)
|
TopoDS_Shape ListOfShapes::Max(gp_Vec dir)
|
||||||
{
|
{
|
||||||
double maxval = -1e99;
|
double maxval = -1e99;
|
||||||
@ -125,13 +127,15 @@ namespace netgen
|
|||||||
|
|
||||||
ListOfShapes ListOfShapes::SubShapes(TopAbs_ShapeEnum type) const
|
ListOfShapes ListOfShapes::SubShapes(TopAbs_ShapeEnum type) const
|
||||||
{
|
{
|
||||||
std::set<TopoDS_Shape> unique_shapes;
|
TopTools_MapOfShape check_unique;
|
||||||
|
ListOfShapes sub;
|
||||||
for(const auto& shape : *this)
|
for(const auto& shape : *this)
|
||||||
for(TopExp_Explorer e(shape, type); e.More(); e.Next())
|
for(TopExp_Explorer e(shape, type); e.More(); e.Next())
|
||||||
unique_shapes.insert(e.Current());
|
if(const auto& s = e.Current(); !check_unique.Contains(s))
|
||||||
ListOfShapes sub;
|
{
|
||||||
for(const auto& shape : unique_shapes)
|
check_unique.Add(s);
|
||||||
sub.push_back(shape);
|
sub.push_back(s);
|
||||||
|
}
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +235,7 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
MeshingParameters local_mp = mparam;
|
MeshingParameters local_mp = mparam;
|
||||||
auto face = TopoDS::Face(fmap(nr+1));
|
auto face = TopoDS::Face(fmap(nr+1));
|
||||||
if(auto quad_dominated = OCCGeometry::global_shape_properties[face].quad_dominated; quad_dominated.has_value())
|
if(auto quad_dominated = OCCGeometry::GetProperties(face).quad_dominated; quad_dominated.has_value())
|
||||||
local_mp.quad = *quad_dominated;
|
local_mp.quad = *quad_dominated;
|
||||||
|
|
||||||
bool failed = OCCMeshFace(*this, mesh, glob2loc, local_mp, nr, PARAMETERSPACE, true);
|
bool failed = OCCMeshFace(*this, mesh, glob2loc, local_mp, nr, PARAMETERSPACE, true);
|
||||||
@ -407,9 +411,9 @@ namespace netgen
|
|||||||
|
|
||||||
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
if (auto name = OCCGeometry::global_shape_properties[e.Current()].name)
|
if (auto name = OCCGeometry::GetProperties(e.Current()).name)
|
||||||
for (auto mods : history->Modified(e.Current()))
|
for (auto mods : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].name = *name;
|
OCCGeometry::GetProperties(mods).name = *name;
|
||||||
}
|
}
|
||||||
#endif // OCC_HAVE_HISTORY
|
#endif // OCC_HAVE_HISTORY
|
||||||
|
|
||||||
@ -475,7 +479,7 @@ namespace netgen
|
|||||||
for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
|
for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
|
||||||
{
|
{
|
||||||
TopoDS_Face face = TopoDS::Face (exp0.Current());
|
TopoDS_Face face = TopoDS::Face (exp0.Current());
|
||||||
auto props = global_shape_properties[face];
|
auto props = GetProperties(face);
|
||||||
|
|
||||||
sff = new ShapeFix_Face (face);
|
sff = new ShapeFix_Face (face);
|
||||||
sff->FixAddNaturalBoundMode() = Standard_True;
|
sff->FixAddNaturalBoundMode() = Standard_True;
|
||||||
@ -506,7 +510,7 @@ namespace netgen
|
|||||||
|
|
||||||
// Set the original properties of the face to the newly created
|
// Set the original properties of the face to the newly created
|
||||||
// face (after the healing process)
|
// face (after the healing process)
|
||||||
global_shape_properties[face];
|
// GetProperties(face);
|
||||||
}
|
}
|
||||||
shape = rebuild->Apply(shape);
|
shape = rebuild->Apply(shape);
|
||||||
}
|
}
|
||||||
@ -1152,8 +1156,8 @@ namespace netgen
|
|||||||
auto occ_vertex = make_unique<OCCVertex>(TopoDS::Vertex(v));
|
auto occ_vertex = make_unique<OCCVertex>(TopoDS::Vertex(v));
|
||||||
occ_vertex->nr = vertices.Size();
|
occ_vertex->nr = vertices.Size();
|
||||||
|
|
||||||
if(global_shape_properties.count(v)>0)
|
if(HaveProperties(v))
|
||||||
occ_vertex->properties = global_shape_properties[v];
|
occ_vertex->properties = GetProperties(v);
|
||||||
vertices.Append(std::move(occ_vertex));
|
vertices.Append(std::move(occ_vertex));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1163,7 +1167,7 @@ namespace netgen
|
|||||||
auto edge = TopoDS::Edge(e);
|
auto edge = TopoDS::Edge(e);
|
||||||
auto verts = GetVertices(e);
|
auto verts = GetVertices(e);
|
||||||
auto occ_edge = make_unique<OCCEdge>(edge, GetVertex(verts[0]), GetVertex(verts[1]) );
|
auto occ_edge = make_unique<OCCEdge>(edge, GetVertex(verts[0]), GetVertex(verts[1]) );
|
||||||
occ_edge->properties = global_shape_properties[e];
|
occ_edge->properties = GetProperties(e);
|
||||||
edges.Append(std::move(occ_edge));
|
edges.Append(std::move(occ_edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1177,8 +1181,8 @@ namespace netgen
|
|||||||
for(auto e : GetEdges(f))
|
for(auto e : GetEdges(f))
|
||||||
occ_face->edges.Append( &GetEdge(e) );
|
occ_face->edges.Append( &GetEdge(e) );
|
||||||
|
|
||||||
if(global_shape_properties.count(f)>0)
|
if(HaveProperties(f))
|
||||||
occ_face->properties = global_shape_properties[f];
|
occ_face->properties = GetProperties(f);
|
||||||
faces.Append(std::move(occ_face));
|
faces.Append(std::move(occ_face));
|
||||||
|
|
||||||
if(dimension==2)
|
if(dimension==2)
|
||||||
@ -1198,8 +1202,8 @@ namespace netgen
|
|||||||
auto s = somap(i1);
|
auto s = somap(i1);
|
||||||
int k = solids.Size();
|
int k = solids.Size();
|
||||||
auto occ_solid = make_unique<OCCSolid>(s);
|
auto occ_solid = make_unique<OCCSolid>(s);
|
||||||
if(global_shape_properties.count(s)>0)
|
if(HaveProperties(s))
|
||||||
occ_solid->properties = global_shape_properties[s];
|
occ_solid->properties = GetProperties(s);
|
||||||
solids.Append(std::move(occ_solid));
|
solids.Append(std::move(occ_solid));
|
||||||
|
|
||||||
for(auto f : GetFaces(s))
|
for(auto f : GetFaces(s))
|
||||||
@ -1218,8 +1222,8 @@ namespace netgen
|
|||||||
for(auto i1 : Range(1, shape_map.Extent()+1))
|
for(auto i1 : Range(1, shape_map.Extent()+1))
|
||||||
{
|
{
|
||||||
auto shape = shape_map(i1);
|
auto shape = shape_map(i1);
|
||||||
if(identifications.count(shape))
|
if(HaveIdentifications(shape))
|
||||||
for(auto & ident : identifications[shape])
|
for(auto & ident : GetIdentifications(shape))
|
||||||
{
|
{
|
||||||
if(!shape_map.Contains(ident.from) || !shape_map.Contains(ident.to))
|
if(!shape_map.Contains(ident.from) || !shape_map.Contains(ident.to))
|
||||||
continue;
|
continue;
|
||||||
@ -1624,33 +1628,33 @@ namespace netgen
|
|||||||
auto occ_hash = key.HashCode(1<<31UL);
|
auto occ_hash = key.HashCode(1<<31UL);
|
||||||
return std::hash<decltype(occ_hash)>()(occ_hash);
|
return std::hash<decltype(occ_hash)>()(occ_hash);
|
||||||
};
|
};
|
||||||
std::map<TopoDS_Shape, int> shape_map;
|
TopTools_IndexedMapOfShape shape_map;
|
||||||
Array<TopoDS_Shape> shape_list;
|
Array<TopoDS_Shape> shape_list;
|
||||||
|
|
||||||
ar & dimension;
|
ar & dimension;
|
||||||
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE })
|
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE })
|
||||||
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto ds = e.Current();
|
auto ds = e.Current();
|
||||||
if(shape_map.count(ds)==0)
|
if(shape_map.FindIndex(ds) == 0)
|
||||||
{
|
{
|
||||||
shape_map[ds] = shape_list.Size();
|
shape_map.Add(ds);
|
||||||
shape_list.Append(ds);
|
shape_list.Append(ds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto s : shape_list)
|
for (auto s : shape_list)
|
||||||
{
|
{
|
||||||
bool has_properties = global_shape_properties.count(s);
|
bool has_properties = HaveProperties(s);
|
||||||
ar & has_properties;
|
ar & has_properties;
|
||||||
if(has_properties)
|
if(has_properties)
|
||||||
ar & global_shape_properties[s];
|
ar & GetProperties(s);
|
||||||
|
|
||||||
bool has_identifications = identifications.count(s);
|
bool has_identifications = HaveIdentifications(s);
|
||||||
ar & has_identifications;
|
ar & has_identifications;
|
||||||
if(has_identifications)
|
if(has_identifications)
|
||||||
{
|
{
|
||||||
auto & idents = identifications[s];
|
auto & idents = GetIdentifications(s);
|
||||||
auto n_idents = idents.size();
|
auto n_idents = idents.size();
|
||||||
ar & n_idents;
|
ar & n_idents;
|
||||||
idents.resize(n_idents);
|
idents.resize(n_idents);
|
||||||
@ -1660,8 +1664,8 @@ namespace netgen
|
|||||||
int id_from, id_to;
|
int id_from, id_to;
|
||||||
if(ar.Output())
|
if(ar.Output())
|
||||||
{
|
{
|
||||||
id_from = shape_map[id.from];
|
id_from = shape_map.FindIndex(id.from)-1;
|
||||||
id_to = shape_map[id.to];
|
id_to = shape_map.FindIndex(id.to)-1;
|
||||||
}
|
}
|
||||||
ar & id_from & id_to & id.trafo & id.name;
|
ar & id_from & id_to & id.trafo & id.name;
|
||||||
if(ar.Input())
|
if(ar.Input())
|
||||||
@ -1989,7 +1993,8 @@ namespace netgen
|
|||||||
if(tree.GetTolerance() < Dist(trafo(c_me), c_you))
|
if(tree.GetTolerance() < Dist(trafo(c_me), c_you))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::map<TopoDS_Shape, optional<TopoDS_Shape>> vmap;
|
TopTools_IndexedMapOfShape vmap;
|
||||||
|
std::vector<optional<TopoDS_Shape>> verts;
|
||||||
|
|
||||||
auto verts_me = GetVertices(me);
|
auto verts_me = GetVertices(me);
|
||||||
auto verts_you = GetVertices(you);
|
auto verts_you = GetVertices(you);
|
||||||
@ -2000,11 +2005,12 @@ namespace netgen
|
|||||||
for (auto i : Range(verts_me.size()))
|
for (auto i : Range(verts_me.size()))
|
||||||
{
|
{
|
||||||
auto s = verts_me[i];
|
auto s = verts_me[i];
|
||||||
if(vmap.count(s)>0)
|
if(vmap.FindIndex(s) > 0)
|
||||||
continue;
|
continue;
|
||||||
auto p = trafo(occ2ng(s));
|
auto p = trafo(occ2ng(s));
|
||||||
tree.Insert( p, i );
|
tree.Insert( p, i );
|
||||||
vmap[s] = nullopt;
|
vmap.Add(s);
|
||||||
|
verts.push_back(nullopt);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto vert : verts_you)
|
for (auto vert : verts_you)
|
||||||
@ -2013,9 +2019,10 @@ namespace netgen
|
|||||||
auto p = occ2ng(s);
|
auto p = occ2ng(s);
|
||||||
bool vert_mapped = false;
|
bool vert_mapped = false;
|
||||||
tree.GetFirstIntersecting( p, p, [&](size_t i ) {
|
tree.GetFirstIntersecting( p, p, [&](size_t i ) {
|
||||||
vmap[verts_me[i]] = s;
|
vmap.Add(verts_me[i]);
|
||||||
vert_mapped = true;
|
verts[vmap.FindIndex(verts_me[i])-1] = s;
|
||||||
return true;
|
vert_mapped = true;
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
if(!vert_mapped)
|
if(!vert_mapped)
|
||||||
return false;
|
return false;
|
||||||
@ -2069,7 +2076,7 @@ namespace netgen
|
|||||||
if(!IsMappedShape(trafo, shape_me, shape_you))
|
if(!IsMappedShape(trafo, shape_me, shape_you))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
OCCGeometry::identifications[shape_me].push_back
|
OCCGeometry::GetIdentifications(shape_me).push_back
|
||||||
(OCCIdentification { shape_me, shape_you, trafo, name, type });
|
(OCCIdentification { shape_me, shape_you, trafo, name, type });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2132,7 +2139,7 @@ namespace netgen
|
|||||||
XCAFPrs_Style aStyle;
|
XCAFPrs_Style aStyle;
|
||||||
set.FindFromKey(e.Current(), aStyle);
|
set.FindFromKey(e.Current(), aStyle);
|
||||||
|
|
||||||
auto & prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto & prop = OCCGeometry::GetProperties(e.Current());
|
||||||
if(aStyle.IsSetColorSurf())
|
if(aStyle.IsSetColorSurf())
|
||||||
prop.col = step_utils::ReadColor(aStyle.GetColorSurfRGBA());
|
prop.col = step_utils::ReadColor(aStyle.GetColorSurfRGBA());
|
||||||
}
|
}
|
||||||
@ -2152,7 +2159,7 @@ namespace netgen
|
|||||||
if (!transProc->IsBound(item))
|
if (!transProc->IsBound(item))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
OCCGeometry::global_shape_properties[shape].name = name;
|
OCCGeometry::GetProperties(shape).name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2176,7 +2183,7 @@ namespace netgen
|
|||||||
if(name != "netgen_geometry_properties")
|
if(name != "netgen_geometry_properties")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto & prop = OCCGeometry::global_shape_properties[shape];
|
auto & prop = OCCGeometry::GetProperties(shape);
|
||||||
|
|
||||||
auto nprops = item->NbItemElement();
|
auto nprops = item->NbItemElement();
|
||||||
|
|
||||||
@ -2202,7 +2209,7 @@ namespace netgen
|
|||||||
Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity(finder, shape);
|
Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity(finder, shape);
|
||||||
if(!item)
|
if(!item)
|
||||||
return;
|
return;
|
||||||
auto prop = OCCGeometry::global_shape_properties[shape];
|
auto prop = OCCGeometry::GetProperties(shape);
|
||||||
|
|
||||||
if(auto n = prop.name)
|
if(auto n = prop.name)
|
||||||
item->SetName(MakeName(*n));
|
item->SetName(MakeName(*n));
|
||||||
@ -2231,7 +2238,9 @@ namespace netgen
|
|||||||
void WriteIdentifications(const Handle(Interface_InterfaceModel) model, const TopoDS_Shape & shape, const Handle(Transfer_FinderProcess) finder)
|
void WriteIdentifications(const Handle(Interface_InterfaceModel) model, const TopoDS_Shape & shape, const Handle(Transfer_FinderProcess) finder)
|
||||||
{
|
{
|
||||||
Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity(finder, shape);
|
Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity(finder, shape);
|
||||||
auto & identifications = OCCGeometry::identifications[shape];
|
if(!OCCGeometry::HaveIdentifications(shape))
|
||||||
|
return;
|
||||||
|
auto & identifications = OCCGeometry::GetIdentifications(shape);
|
||||||
if(identifications.size()==0)
|
if(identifications.size()==0)
|
||||||
return;
|
return;
|
||||||
auto n = identifications.size();
|
auto n = identifications.size();
|
||||||
@ -2282,7 +2291,7 @@ namespace netgen
|
|||||||
|
|
||||||
result.push_back(ident);
|
result.push_back(ident);
|
||||||
}
|
}
|
||||||
OCCGeometry::identifications[shape_origin] = result;
|
OCCGeometry::GetIdentifications(shape_origin) = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteSTEP(const TopoDS_Shape & shape, const filesystem::path & filename)
|
void WriteSTEP(const TopoDS_Shape & shape, const filesystem::path & filename)
|
||||||
@ -2306,7 +2315,7 @@ namespace netgen
|
|||||||
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE })
|
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE })
|
||||||
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
if(auto col = prop.col)
|
if(auto col = prop.col)
|
||||||
colortool->SetColor(e.Current(), step_utils::MakeColor(*col), XCAFDoc_ColorGen);
|
colortool->SetColor(e.Current(), step_utils::MakeColor(*col), XCAFDoc_ColorGen);
|
||||||
}
|
}
|
||||||
|
@ -31,20 +31,6 @@
|
|||||||
#define OCC_HAVE_HISTORY
|
#define OCC_HAVE_HISTORY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
template<>
|
|
||||||
struct less<TopoDS_Shape>
|
|
||||||
{
|
|
||||||
bool operator() (const TopoDS_Shape& s1, const TopoDS_Shape& s2) const
|
|
||||||
{
|
|
||||||
return s1.HashCode(std::numeric_limits<Standard_Integer>::max()) <
|
|
||||||
s2.HashCode(std::numeric_limits<Standard_Integer>::max());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -149,8 +135,38 @@ namespace netgen
|
|||||||
Point<3> center;
|
Point<3> center;
|
||||||
OCCParameters occparam;
|
OCCParameters occparam;
|
||||||
public:
|
public:
|
||||||
static std::map<TopoDS_Shape, ShapeProperties> global_shape_properties;
|
static TopTools_IndexedMapOfShape global_shape_property_indices;
|
||||||
static std::map<TopoDS_Shape, std::vector<OCCIdentification>> identifications;
|
static std::vector<ShapeProperties> global_shape_properties;
|
||||||
|
static TopTools_IndexedMapOfShape global_identification_indices;
|
||||||
|
static std::vector<std::vector<OCCIdentification>> global_identifications;
|
||||||
|
|
||||||
|
static ShapeProperties& GetProperties(const TopoDS_Shape& shape)
|
||||||
|
{
|
||||||
|
auto index = OCCGeometry::global_shape_property_indices.FindIndex(shape);
|
||||||
|
if(index > 0)
|
||||||
|
return OCCGeometry::global_shape_properties
|
||||||
|
[index-1];
|
||||||
|
OCCGeometry::global_shape_property_indices.Add(shape);
|
||||||
|
OCCGeometry::global_shape_properties.push_back({});
|
||||||
|
return OCCGeometry::global_shape_properties.back();
|
||||||
|
}
|
||||||
|
static bool HaveProperties(const TopoDS_Shape& shape)
|
||||||
|
{
|
||||||
|
return OCCGeometry::global_shape_property_indices.FindIndex(shape) > 1;
|
||||||
|
}
|
||||||
|
static std::vector<OCCIdentification>& GetIdentifications(const TopoDS_Shape& shape)
|
||||||
|
{
|
||||||
|
auto index = OCCGeometry::global_identification_indices.FindIndex(shape);
|
||||||
|
if(index > 0)
|
||||||
|
return OCCGeometry::global_identifications[index-1];
|
||||||
|
OCCGeometry::global_identification_indices.Add(shape);
|
||||||
|
OCCGeometry::global_identifications.push_back({});
|
||||||
|
return OCCGeometry::global_identifications.back();
|
||||||
|
}
|
||||||
|
static bool HaveIdentifications(const TopoDS_Shape& shape)
|
||||||
|
{
|
||||||
|
return OCCGeometry::global_identification_indices.FindIndex(shape) > 1;
|
||||||
|
}
|
||||||
|
|
||||||
TopoDS_Shape shape;
|
TopoDS_Shape shape;
|
||||||
TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
|
TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
|
||||||
@ -422,8 +438,10 @@ namespace netgen
|
|||||||
template <class TBuilder>
|
template <class TBuilder>
|
||||||
void PropagateIdentifications (TBuilder & builder, TopoDS_Shape shape, std::optional<Transformation<3>> trafo = nullopt)
|
void PropagateIdentifications (TBuilder & builder, TopoDS_Shape shape, std::optional<Transformation<3>> trafo = nullopt)
|
||||||
{
|
{
|
||||||
std::map<TopoDS_Shape, std::set<TopoDS_Shape>> mod_map;
|
TopTools_IndexedMapOfShape mod_indices;
|
||||||
std::map<TopoDS_Shape, bool> shape_handled;
|
Array<TopTools_IndexedMapOfShape> modifications;
|
||||||
|
TopTools_MapOfShape shape_handled;
|
||||||
|
|
||||||
Transformation<3> trafo_inv;
|
Transformation<3> trafo_inv;
|
||||||
if(trafo)
|
if(trafo)
|
||||||
trafo_inv = trafo->CalcInverse();
|
trafo_inv = trafo->CalcInverse();
|
||||||
@ -432,8 +450,9 @@ namespace netgen
|
|||||||
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto s = e.Current();
|
auto s = e.Current();
|
||||||
mod_map[s].insert(s);
|
mod_indices.Add(s);
|
||||||
shape_handled[s] = false;
|
modifications.Append(TopTools_IndexedMapOfShape());
|
||||||
|
modifications.Last().Add(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX })
|
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX })
|
||||||
@ -441,7 +460,10 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
auto s = e.Current();
|
auto s = e.Current();
|
||||||
for (auto mods : builder.Modified(s))
|
for (auto mods : builder.Modified(s))
|
||||||
mod_map[s].insert(mods);
|
{
|
||||||
|
auto index = mod_indices.FindIndex(s)-1;
|
||||||
|
modifications[index].Add(mods);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX })
|
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX })
|
||||||
@ -449,27 +471,35 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
auto s = e.Current();
|
auto s = e.Current();
|
||||||
|
|
||||||
if(shape_handled[s])
|
if(shape_handled.Contains(s))
|
||||||
continue;
|
continue;
|
||||||
shape_handled[s] = true;
|
shape_handled.Add(s);
|
||||||
|
|
||||||
|
if(!OCCGeometry::HaveIdentifications(s))
|
||||||
|
continue;
|
||||||
|
auto& identifications = OCCGeometry::GetIdentifications(s);
|
||||||
|
|
||||||
|
auto& shape_mapped = modifications[mod_indices.FindIndex(s)-1];
|
||||||
|
|
||||||
if(OCCGeometry::identifications.count(s)==0)
|
for(auto ident : identifications)
|
||||||
continue;
|
|
||||||
|
|
||||||
auto shape_mapped = mod_map[s];
|
|
||||||
|
|
||||||
for(auto ident : OCCGeometry::identifications[s])
|
|
||||||
{
|
{
|
||||||
// nothing happened
|
auto i1 = mod_indices.FindIndex(ident.to);
|
||||||
if(mod_map[ident.to].size()==1 && mod_map[ident.from].size() ==1)
|
auto i2 = mod_indices.FindIndex(ident.from);
|
||||||
continue;
|
if(i1 == 0 || i2 == 0) // not in geometry
|
||||||
|
continue;
|
||||||
|
auto& mods_to = modifications[i1-1];
|
||||||
|
auto& mods_from = modifications[i2-1];
|
||||||
|
if(mods_to.Extent()==1 && mods_from.Extent() ==1)
|
||||||
|
continue;
|
||||||
|
|
||||||
auto from = ident.from;
|
auto from = ident.from;
|
||||||
auto to = ident.to;
|
auto to = ident.to;
|
||||||
|
|
||||||
for(auto from_mapped : mod_map[from])
|
for(auto it = mods_from.cbegin(); it != mods_from.cend(); it++)
|
||||||
for(auto to_mapped : mod_map[to])
|
for(auto it2 = mods_to.cbegin(); it2 != mods_to.cend(); it2++)
|
||||||
{
|
{
|
||||||
|
auto& from_mapped = it.Iterator().Value();
|
||||||
|
auto& to_mapped = it2.Iterator().Value();
|
||||||
if(from.IsSame(from_mapped) && to.IsSame(to_mapped))
|
if(from.IsSame(from_mapped) && to.IsSame(to_mapped))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -489,7 +519,7 @@ namespace netgen
|
|||||||
id_new.from = from_mapped;
|
id_new.from = from_mapped;
|
||||||
id_new.trafo = trafo_mapped;
|
id_new.trafo = trafo_mapped;
|
||||||
auto id_owner = from.IsSame(s) ? from_mapped : to_mapped;
|
auto id_owner = from.IsSame(s) ? from_mapped : to_mapped;
|
||||||
OCCGeometry::identifications[id_owner].push_back(id_new);
|
OCCGeometry::GetIdentifications(id_owner).push_back(id_new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,10 +534,12 @@ namespace netgen
|
|||||||
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto s = e.Current();
|
auto s = e.Current();
|
||||||
auto & prop = OCCGeometry::global_shape_properties[s];
|
have_identifications |= OCCGeometry::HaveIdentifications(s);
|
||||||
|
if(!OCCGeometry::HaveProperties(s))
|
||||||
|
continue;
|
||||||
|
auto & prop = OCCGeometry::GetProperties(s);
|
||||||
for (auto mods : builder.Modified(s))
|
for (auto mods : builder.Modified(s))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
have_identifications |= OCCGeometry::identifications.count(s) > 0;
|
|
||||||
}
|
}
|
||||||
if(have_identifications)
|
if(have_identifications)
|
||||||
PropagateIdentifications(builder, shape, trafo);
|
PropagateIdentifications(builder, shape, trafo);
|
||||||
|
@ -118,11 +118,11 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
|
|
||||||
for (auto & s : shapes)
|
for (auto & s : shapes)
|
||||||
for (TopExp_Explorer e(s, TopAbs_SOLID); e.More(); e.Next())
|
for (TopExp_Explorer e(s, TopAbs_SOLID); e.More(); e.Next())
|
||||||
if (auto name = OCCGeometry::global_shape_properties[e.Current()].name)
|
if (auto name = OCCGeometry::GetProperties(e.Current()).name)
|
||||||
{
|
{
|
||||||
TopTools_ListOfShape modlist = history->Modified(e.Current());
|
TopTools_ListOfShape modlist = history->Modified(e.Current());
|
||||||
for (auto mods : modlist)
|
for (auto mods : modlist)
|
||||||
OCCGeometry::global_shape_properties[mods].name = *name;
|
OCCGeometry::GetProperties(mods).name = *name;
|
||||||
}
|
}
|
||||||
#endif // OCC_HAVE_HISTORY
|
#endif // OCC_HAVE_HISTORY
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ public:
|
|||||||
|
|
||||||
// auto edge = BRepBuilderAPI_MakeEdge(curve).Edge();
|
// auto edge = BRepBuilderAPI_MakeEdge(curve).Edge();
|
||||||
if (name)
|
if (name)
|
||||||
OCCGeometry::global_shape_properties[edge].name = name;
|
OCCGeometry::GetProperties(edge).name = name;
|
||||||
wire_builder.Add(edge);
|
wire_builder.Add(edge);
|
||||||
|
|
||||||
if (closing) Finish();
|
if (closing) Finish();
|
||||||
@ -591,7 +591,7 @@ public:
|
|||||||
auto NameVertex (string name)
|
auto NameVertex (string name)
|
||||||
{
|
{
|
||||||
if (!lastvertex.IsNull())
|
if (!lastvertex.IsNull())
|
||||||
OCCGeometry::global_shape_properties[lastvertex].name = name;
|
OCCGeometry::GetProperties(lastvertex).name = name;
|
||||||
return shared_from_this();
|
return shared_from_this();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,37 +814,37 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
.def("bc", [](const TopoDS_Shape & shape, const string & name)
|
.def("bc", [](const TopoDS_Shape & shape, const string & name)
|
||||||
{
|
{
|
||||||
for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next())
|
||||||
OCCGeometry::global_shape_properties[e.Current()].name = name;
|
OCCGeometry::GetProperties(e.Current()).name = name;
|
||||||
return shape;
|
return shape;
|
||||||
}, py::arg("name"), "sets 'name' property for all faces of shape")
|
}, py::arg("name"), "sets 'name' property for all faces of shape")
|
||||||
|
|
||||||
.def("mat", [](const TopoDS_Shape & shape, const string & name)
|
.def("mat", [](const TopoDS_Shape & shape, const string & name)
|
||||||
{
|
{
|
||||||
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
||||||
OCCGeometry::global_shape_properties[e.Current()].name = name;
|
OCCGeometry::GetProperties(e.Current()).name = name;
|
||||||
return shape;
|
return shape;
|
||||||
}, py::arg("name"), "sets 'name' property to all solids of shape")
|
}, py::arg("name"), "sets 'name' property to all solids of shape")
|
||||||
|
|
||||||
.def_property("name", [](const TopoDS_Shape & self) -> optional<string> {
|
.def_property("name", [](const TopoDS_Shape & self) -> optional<string> {
|
||||||
if (auto name = OCCGeometry::global_shape_properties[self].name)
|
if (auto name = OCCGeometry::GetProperties(self).name)
|
||||||
return *name;
|
return *name;
|
||||||
else
|
else
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}, [](const TopoDS_Shape & self, optional<string> name) {
|
}, [](const TopoDS_Shape & self, optional<string> name) {
|
||||||
OCCGeometry::global_shape_properties[self].name = name;
|
OCCGeometry::GetProperties(self).name = name;
|
||||||
}, "'name' of shape")
|
}, "'name' of shape")
|
||||||
|
|
||||||
.def_property("maxh",
|
.def_property("maxh",
|
||||||
[](const TopoDS_Shape& self)
|
[](const TopoDS_Shape& self)
|
||||||
{
|
{
|
||||||
return OCCGeometry::global_shape_properties[self].maxh;
|
return OCCGeometry::GetProperties(self).maxh;
|
||||||
},
|
},
|
||||||
[](TopoDS_Shape& self, double val)
|
[](TopoDS_Shape& self, double val)
|
||||||
{
|
{
|
||||||
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX })
|
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX })
|
||||||
for (TopExp_Explorer e(self, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(self, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto & maxh = OCCGeometry::global_shape_properties[e.Current()].maxh;
|
auto & maxh = OCCGeometry::GetProperties(e.Current()).maxh;
|
||||||
maxh = min2(val, maxh);
|
maxh = min2(val, maxh);
|
||||||
}
|
}
|
||||||
}, "maximal mesh-size for shape")
|
}, "maximal mesh-size for shape")
|
||||||
@ -852,25 +852,24 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
.def_property("hpref",
|
.def_property("hpref",
|
||||||
[](const TopoDS_Shape& self)
|
[](const TopoDS_Shape& self)
|
||||||
{
|
{
|
||||||
return OCCGeometry::global_shape_properties[self].hpref;
|
return OCCGeometry::GetProperties(self).hpref;
|
||||||
},
|
},
|
||||||
[](TopoDS_Shape& self, double val)
|
[](TopoDS_Shape& self, double val)
|
||||||
{
|
{
|
||||||
auto & hpref = OCCGeometry::global_shape_properties[self].hpref;
|
auto & hpref = OCCGeometry::GetProperties(self).hpref;
|
||||||
hpref = max2(val, hpref);
|
hpref = max2(val, hpref);
|
||||||
}, "number of refinement levels for geometric refinement")
|
}, "number of refinement levels for geometric refinement")
|
||||||
|
|
||||||
.def_property("col", [](const TopoDS_Shape & self) {
|
.def_property("col", [](const TopoDS_Shape & self) {
|
||||||
auto it = OCCGeometry::global_shape_properties.find(self);
|
if(!OCCGeometry::HaveProperties(self) || !OCCGeometry::GetProperties(self).col)
|
||||||
Vec<4> col(0.2, 0.2, 0.2);
|
return std::vector<double>({ 0.2, 0.2, 0.2, 1. });
|
||||||
if (it != OCCGeometry::global_shape_properties.end() && it->second.col)
|
auto col = *OCCGeometry::GetProperties(self).col;
|
||||||
col = *it->second.col;
|
return std::vector<double>({ col(0), col(1), col(2), col(3) });
|
||||||
return std::vector<double> ( { col(0), col(1), col(2) } );
|
}, [](const TopoDS_Shape & self, std::vector<double> c) {
|
||||||
}, [](const TopoDS_Shape & self, std::vector<double> c) {
|
|
||||||
Vec<4> col(c[0], c[1], c[2], 1.0);
|
Vec<4> col(c[0], c[1], c[2], 1.0);
|
||||||
if(c.size() == 4)
|
if(c.size() == 4)
|
||||||
col[3] = c[3];
|
col[3] = c[3];
|
||||||
OCCGeometry::global_shape_properties[self].col = col;
|
OCCGeometry::GetProperties(self).col = col;
|
||||||
}, "color of shape as RGB - tuple")
|
}, "color of shape as RGB - tuple")
|
||||||
.def("UnifySameDomain", [](const TopoDS_Shape& shape,
|
.def("UnifySameDomain", [](const TopoDS_Shape& shape,
|
||||||
bool edges, bool faces,
|
bool edges, bool faces,
|
||||||
@ -883,9 +882,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE })
|
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE })
|
||||||
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
for (auto mods : history->Modified(e.Current()))
|
for (auto mods : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
}
|
}
|
||||||
return unify.Shape();
|
return unify.Shape();
|
||||||
}, py::arg("unifyEdges")=true, py::arg("unifyFaces")=true,
|
}, py::arg("unifyEdges")=true, py::arg("unifyFaces")=true,
|
||||||
@ -911,9 +910,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
for (auto & s : { shape1, shape2 })
|
for (auto & s : { shape1, shape2 })
|
||||||
for (TopExp_Explorer e(s, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(s, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
for (auto mods : history->Modified(e.Current()))
|
for (auto mods : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
@ -937,9 +936,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE })
|
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE })
|
||||||
for (TopExp_Explorer e(fused, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(fused, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
for (auto mods : history->Modified(e.Current()))
|
for (auto mods : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
// PropagateProperties (unify, fused);
|
// PropagateProperties (unify, fused);
|
||||||
@ -963,9 +962,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
for (auto & s : { shape1, shape2 })
|
for (auto & s : { shape1, shape2 })
|
||||||
for (TopExp_Explorer e(s, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(s, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
for (auto mods : history->Modified(e.Current()))
|
for (auto mods : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
}
|
}
|
||||||
#endif // OCC_HAVE_HISTORY
|
#endif // OCC_HAVE_HISTORY
|
||||||
*/
|
*/
|
||||||
@ -986,9 +985,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
for (auto & s : { shape1, shape2 })
|
for (auto & s : { shape1, shape2 })
|
||||||
for (TopExp_Explorer e(s, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(s, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
for (auto mods : history->Modified(e.Current()))
|
for (auto mods : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
}
|
}
|
||||||
#endif // OCC_HAVE_HISTORY
|
#endif // OCC_HAVE_HISTORY
|
||||||
*/
|
*/
|
||||||
@ -1001,7 +1000,8 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
return shape1.IsSame(shape2);
|
return shape1.IsSame(shape2);
|
||||||
})
|
})
|
||||||
.def("__hash__", [] (const TopoDS_Shape& shape) {
|
.def("__hash__", [] (const TopoDS_Shape& shape) {
|
||||||
return shape.HashCode(std::numeric_limits<Standard_Integer>::max());
|
OCCGeometry::GetProperties(shape); // make sure it is in global properties
|
||||||
|
return OCCGeometry::global_shape_property_indices.FindIndex(shape);
|
||||||
})
|
})
|
||||||
|
|
||||||
.def("Reversed", [](const TopoDS_Shape & shape) {
|
.def("Reversed", [](const TopoDS_Shape & shape) {
|
||||||
@ -1027,9 +1027,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX })
|
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX })
|
||||||
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
for (auto mods : builder.Generated(e.Current()))
|
for (auto mods : builder.Generated(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.Shape();
|
return builder.Shape();
|
||||||
@ -1050,9 +1050,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
for (auto typ : { TopAbs_EDGE, TopAbs_VERTEX })
|
for (auto typ : { TopAbs_EDGE, TopAbs_VERTEX })
|
||||||
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
for (auto mods : builder.Generated(e.Current()))
|
for (auto mods : builder.Generated(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.Shape();
|
return builder.Shape();
|
||||||
@ -1068,7 +1068,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
PropagateProperties (mkFillet, shape);
|
PropagateProperties (mkFillet, shape);
|
||||||
for (auto e : edges)
|
for (auto e : edges)
|
||||||
for (auto gen : mkFillet.Generated(e))
|
for (auto gen : mkFillet.Generated(e))
|
||||||
OCCGeometry::global_shape_properties[gen].name = "fillet";
|
OCCGeometry::GetProperties(gen).name = "fillet";
|
||||||
return mkFillet.Shape();
|
return mkFillet.Shape();
|
||||||
}, py::arg("edges"), py::arg("r"), "make fillets for edges 'edges' of radius 'r'")
|
}, py::arg("edges"), py::arg("r"), "make fillets for edges 'edges' of radius 'r'")
|
||||||
|
|
||||||
@ -1081,7 +1081,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
PropagateProperties (mkChamfer, shape);
|
PropagateProperties (mkChamfer, shape);
|
||||||
for (auto e : edges)
|
for (auto e : edges)
|
||||||
for (auto gen : mkChamfer.Generated(e))
|
for (auto gen : mkChamfer.Generated(e))
|
||||||
OCCGeometry::global_shape_properties[gen].name = "chamfer";
|
OCCGeometry::GetProperties(gen).name = "chamfer";
|
||||||
return mkChamfer.Shape();
|
return mkChamfer.Shape();
|
||||||
#else
|
#else
|
||||||
throw Exception("MakeChamfer not available for occ-version < 7.4");
|
throw Exception("MakeChamfer not available for occ-version < 7.4");
|
||||||
@ -1189,7 +1189,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
// Handle(TopoDS_Face) face = e.Current();
|
// Handle(TopoDS_Face) face = e.Current();
|
||||||
fmap.Add(face);
|
fmap.Add(face);
|
||||||
ExtractFaceData(face, index, p, n, box);
|
ExtractFaceData(face, index, p, n, box);
|
||||||
auto & props = OCCGeometry::global_shape_properties[face];
|
auto & props = OCCGeometry::GetProperties(face);
|
||||||
if(props.col)
|
if(props.col)
|
||||||
{
|
{
|
||||||
auto & c = *props.col;
|
auto & c = *props.col;
|
||||||
@ -1212,7 +1212,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
for(auto& face : GetFaces(solid))
|
for(auto& face : GetFaces(solid))
|
||||||
faces.push_back(fmap.FindIndex(face)-1);
|
faces.push_back(fmap.FindIndex(face)-1);
|
||||||
solid_face_map.push_back(move(faces));
|
solid_face_map.push_back(move(faces));
|
||||||
auto& props = OCCGeometry::global_shape_properties[solid];
|
auto& props = OCCGeometry::GetProperties(solid);
|
||||||
if(props.name)
|
if(props.name)
|
||||||
solid_names.append(*props.name);
|
solid_names.append(*props.name);
|
||||||
else
|
else
|
||||||
@ -1226,7 +1226,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
{
|
{
|
||||||
TopoDS_Edge edge = TopoDS::Edge(e.Current());
|
TopoDS_Edge edge = TopoDS::Edge(e.Current());
|
||||||
ExtractEdgeData(edge, index, edge_p, box);
|
ExtractEdgeData(edge, index, edge_p, box);
|
||||||
auto & props = OCCGeometry::global_shape_properties[edge];
|
auto & props = OCCGeometry::GetProperties(edge);
|
||||||
if(props.col)
|
if(props.col)
|
||||||
{
|
{
|
||||||
auto & c = *props.col;
|
auto & c = *props.col;
|
||||||
@ -1454,11 +1454,11 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
}))
|
}))
|
||||||
.def_property("quad_dominated", [](const TopoDS_Face& self) -> optional<bool>
|
.def_property("quad_dominated", [](const TopoDS_Face& self) -> optional<bool>
|
||||||
{
|
{
|
||||||
return OCCGeometry::global_shape_properties[self].quad_dominated;
|
return OCCGeometry::GetProperties(self).quad_dominated;
|
||||||
},
|
},
|
||||||
[](TopoDS_Face& self, optional<bool> quad_dominated)
|
[](TopoDS_Face& self, optional<bool> quad_dominated)
|
||||||
{
|
{
|
||||||
OCCGeometry::global_shape_properties[self].quad_dominated = quad_dominated;
|
OCCGeometry::GetProperties(self).quad_dominated = quad_dominated;
|
||||||
})
|
})
|
||||||
.def_property_readonly("surf", [] (TopoDS_Face face) -> Handle(Geom_Surface)
|
.def_property_readonly("surf", [] (TopoDS_Face face) -> Handle(Geom_Surface)
|
||||||
{
|
{
|
||||||
@ -1507,15 +1507,14 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
builder.Add(comp, shapes[i]);
|
builder.Add(comp, shapes[i]);
|
||||||
if(separate_layers)
|
if(separate_layers)
|
||||||
{
|
{
|
||||||
auto & props = OCCGeometry::global_shape_properties;
|
|
||||||
for(auto & s : GetSolids(shapes[i]))
|
for(auto & s : GetSolids(shapes[i]))
|
||||||
props[s].layer = i+1;
|
OCCGeometry::GetProperties(s).layer = i+1;
|
||||||
for(auto & s : GetFaces(shapes[i]))
|
for(auto & s : GetFaces(shapes[i]))
|
||||||
props[s].layer = i+1;
|
OCCGeometry::GetProperties(s).layer = i+1;
|
||||||
for(auto & s : GetEdges(shapes[i]))
|
for(auto & s : GetEdges(shapes[i]))
|
||||||
props[s].layer = i+1;
|
OCCGeometry::GetProperties(s).layer = i+1;
|
||||||
for(auto & s : GetVertices(shapes[i]))
|
for(auto & s : GetVertices(shapes[i]))
|
||||||
props[s].layer = i+1;
|
OCCGeometry::GetProperties(s).layer = i+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1597,7 +1596,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
ListOfShapes selected;
|
ListOfShapes selected;
|
||||||
std::regex pattern(name);
|
std::regex pattern(name);
|
||||||
for (auto s : self)
|
for (auto s : self)
|
||||||
if (auto sname = OCCGeometry::global_shape_properties[s].name)
|
if (auto sname = OCCGeometry::GetProperties(s).name)
|
||||||
if (std::regex_match(*sname, pattern))
|
if (std::regex_match(*sname, pattern))
|
||||||
selected.push_back(s);
|
selected.push_back(s);
|
||||||
return selected;
|
return selected;
|
||||||
@ -1620,9 +1619,13 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
|
|
||||||
.def("Sorted",[](ListOfShapes self, gp_Vec dir)
|
.def("Sorted",[](ListOfShapes self, gp_Vec dir)
|
||||||
{
|
{
|
||||||
std::map<TopoDS_Shape, double> sortval;
|
TopTools_IndexedMapOfShape indices;
|
||||||
|
std::vector<double> sortval;
|
||||||
|
|
||||||
for (auto shape : self)
|
for (auto shape : self)
|
||||||
{
|
{
|
||||||
|
if(indices.FindIndex(shape) > 0)
|
||||||
|
continue;
|
||||||
GProp_GProps props;
|
GProp_GProps props;
|
||||||
gp_Pnt center;
|
gp_Pnt center;
|
||||||
|
|
||||||
@ -1640,12 +1643,14 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
double val = center.X()*dir.X() + center.Y()*dir.Y() + center.Z() * dir.Z();
|
double val = center.X()*dir.X() + center.Y()*dir.Y() + center.Z() * dir.Z();
|
||||||
sortval[shape] = val;
|
indices.Add(shape);
|
||||||
|
sortval.push_back(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort (std::begin(self), std::end(self),
|
std::sort (std::begin(self), std::end(self),
|
||||||
[&](const TopoDS_Shape& a, const TopoDS_Shape& b)
|
[&](const TopoDS_Shape& a, const TopoDS_Shape& b)
|
||||||
{ return sortval[a] < sortval[b]; });
|
{ return sortval[indices.FindIndex(a)-1] <
|
||||||
|
sortval[indices.FindIndex(b)-1]; });
|
||||||
return self;
|
return self;
|
||||||
}, py::arg("dir"), "returns list of shapes, where center of gravity is sorted in direction of 'dir'")
|
}, py::arg("dir"), "returns list of shapes, where center of gravity is sorted in direction of 'dir'")
|
||||||
|
|
||||||
@ -1672,7 +1677,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
{
|
{
|
||||||
for(auto& shape : shapes)
|
for(auto& shape : shapes)
|
||||||
{
|
{
|
||||||
OCCGeometry::global_shape_properties[shape].name = name;
|
OCCGeometry::GetProperties(shape).name = name;
|
||||||
}
|
}
|
||||||
}, "set name for all elements of list")
|
}, "set name for all elements of list")
|
||||||
.def_property("col", [](ListOfShapes& shapes) {
|
.def_property("col", [](ListOfShapes& shapes) {
|
||||||
@ -1682,7 +1687,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
if(c.size() == 4)
|
if(c.size() == 4)
|
||||||
col[3] = c[3];
|
col[3] = c[3];
|
||||||
for(auto& shape : shapes)
|
for(auto& shape : shapes)
|
||||||
OCCGeometry::global_shape_properties[shape].col = col;
|
OCCGeometry::GetProperties(shape).col = col;
|
||||||
}, "set col for all elements of list")
|
}, "set col for all elements of list")
|
||||||
|
|
||||||
.def_property("maxh", [](ListOfShapes& shapes)
|
.def_property("maxh", [](ListOfShapes& shapes)
|
||||||
@ -1694,13 +1699,13 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
for(auto& shape : shapes)
|
for(auto& shape : shapes)
|
||||||
{
|
{
|
||||||
for(auto& s : GetSolids(shape))
|
for(auto& s : GetSolids(shape))
|
||||||
OCCGeometry::global_shape_properties[s].maxh = maxh;
|
OCCGeometry::GetProperties(s).maxh = maxh;
|
||||||
for(auto& s : GetFaces(shape))
|
for(auto& s : GetFaces(shape))
|
||||||
OCCGeometry::global_shape_properties[s].maxh = maxh;
|
OCCGeometry::GetProperties(s).maxh = maxh;
|
||||||
for(auto& s : GetEdges(shape))
|
for(auto& s : GetEdges(shape))
|
||||||
OCCGeometry::global_shape_properties[s].maxh = maxh;
|
OCCGeometry::GetProperties(s).maxh = maxh;
|
||||||
for(auto& s : GetVertices(shape))
|
for(auto& s : GetVertices(shape))
|
||||||
OCCGeometry::global_shape_properties[s].maxh = maxh;
|
OCCGeometry::GetProperties(s).maxh = maxh;
|
||||||
}
|
}
|
||||||
}, "set maxh for all elements of list")
|
}, "set maxh for all elements of list")
|
||||||
.def_property("hpref", [](ListOfShapes& shapes)
|
.def_property("hpref", [](ListOfShapes& shapes)
|
||||||
@ -1711,7 +1716,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
{
|
{
|
||||||
for(auto& shape : shapes)
|
for(auto& shape : shapes)
|
||||||
{
|
{
|
||||||
auto& val = OCCGeometry::global_shape_properties[shape].hpref;
|
auto& val = OCCGeometry::GetProperties(shape).hpref;
|
||||||
val = max2(hpref, val);
|
val = max2(hpref, val);
|
||||||
}
|
}
|
||||||
}, "set hpref for all elements of list")
|
}, "set hpref for all elements of list")
|
||||||
@ -1722,7 +1727,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
[](ListOfShapes& shapes, optional<bool> quad_dominated)
|
[](ListOfShapes& shapes, optional<bool> quad_dominated)
|
||||||
{
|
{
|
||||||
for(auto& shape : shapes)
|
for(auto& shape : shapes)
|
||||||
OCCGeometry::global_shape_properties[shape].quad_dominated = quad_dominated;
|
OCCGeometry::GetProperties(shape).quad_dominated = quad_dominated;
|
||||||
})
|
})
|
||||||
|
|
||||||
.def("Identify", [](const ListOfShapes& me,
|
.def("Identify", [](const ListOfShapes& me,
|
||||||
@ -1820,7 +1825,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
optional<string> bot, optional<string> top, optional<string> mantle) {
|
optional<string> bot, optional<string> top, optional<string> mantle) {
|
||||||
auto builder = BRepPrimAPI_MakeCylinder (gp_Ax2(cpnt, cdir), r, h);
|
auto builder = BRepPrimAPI_MakeCylinder (gp_Ax2(cpnt, cdir), r, h);
|
||||||
if(mantle)
|
if(mantle)
|
||||||
OCCGeometry::global_shape_properties[builder.Face()].name = *mantle;
|
OCCGeometry::GetProperties(builder.Face()).name = *mantle;
|
||||||
auto pyshape = py::cast(builder.Solid());
|
auto pyshape = py::cast(builder.Solid());
|
||||||
gp_Vec v = cdir;
|
gp_Vec v = cdir;
|
||||||
if(bot)
|
if(bot)
|
||||||
@ -2073,9 +2078,9 @@ tangents : Dict[int, gp_Vec2d]
|
|||||||
for (auto & s : shapes)
|
for (auto & s : shapes)
|
||||||
for (TopExp_Explorer e(s, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(s, typ); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
for (auto mods : history->Modified(e.Current()))
|
for (auto mods : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
}
|
}
|
||||||
#endif // OCC_HAVE_HISTORY
|
#endif // OCC_HAVE_HISTORY
|
||||||
*/
|
*/
|
||||||
@ -2104,9 +2109,9 @@ tangents : Dict[int, gp_Vec2d]
|
|||||||
|
|
||||||
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
auto prop = OCCGeometry::global_shape_properties[e.Current()];
|
auto prop = OCCGeometry::GetProperties(e.Current());
|
||||||
for (auto mods : history->Modified(e.Current()))
|
for (auto mods : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_properties[mods].Merge(prop);
|
OCCGeometry::GetProperties(mods).Merge(prop);
|
||||||
}
|
}
|
||||||
#endif // OCC_HAVE_HISTORY
|
#endif // OCC_HAVE_HISTORY
|
||||||
*/
|
*/
|
||||||
|
@ -548,7 +548,7 @@ namespace netgen
|
|||||||
|
|
||||||
if (!occgeometry->fvispar[i-1].IsHighlighted())
|
if (!occgeometry->fvispar[i-1].IsHighlighted())
|
||||||
{
|
{
|
||||||
auto c = OCCGeometry::global_shape_properties[face].col.value_or(Vec<4>(0,1,0,1) );
|
auto c = OCCGeometry::GetProperties(face).col.value_or(Vec<4>(0,1,0,1) );
|
||||||
for(auto j : Range(4))
|
for(auto j : Range(4))
|
||||||
mat_col[j] = c[j];
|
mat_col[j] = c[j];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user