mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-24 03:40:34 +05:00
Don't use std::map<TopoDS_Shape> (hash value is not unique)
This commit is contained in:
parent
f87aa9e7d0
commit
22d314a1ec
@ -230,11 +230,6 @@ namespace netgen
|
|||||||
|
|
||||||
void NetgenGeometry :: Clear()
|
void NetgenGeometry :: Clear()
|
||||||
{
|
{
|
||||||
vertex_map.clear();
|
|
||||||
edge_map.clear();
|
|
||||||
face_map.clear();
|
|
||||||
solid_map.clear();
|
|
||||||
|
|
||||||
vertices.SetSize0();
|
vertices.SetSize0();
|
||||||
edges.SetSize0();
|
edges.SetSize0();
|
||||||
faces.SetSize0();
|
faces.SetSize0();
|
||||||
|
@ -188,10 +188,6 @@ namespace netgen
|
|||||||
Box<3> bounding_box;
|
Box<3> bounding_box;
|
||||||
int dimension = 3;
|
int dimension = 3;
|
||||||
|
|
||||||
std::map<size_t, GeometryVertex*> vertex_map;
|
|
||||||
std::map<size_t, GeometryEdge*> edge_map;
|
|
||||||
std::map<size_t, GeometryFace*> face_map;
|
|
||||||
std::map<size_t, GeometrySolid*> solid_map;
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NetgenGeometry()
|
NetgenGeometry()
|
||||||
@ -208,7 +204,7 @@ namespace netgen
|
|||||||
const GeometryEdge & GetEdge(int i) const { return *edges[i]; }
|
const GeometryEdge & GetEdge(int i) const { return *edges[i]; }
|
||||||
const GeometryVertex & GetVertex(int i) const { return *vertices[i]; }
|
const GeometryVertex & GetVertex(int i) const { return *vertices[i]; }
|
||||||
|
|
||||||
virtual Array<GeometryVertex*> GetFaceVertices(const GeometryFace& face) const { return Array<GeometryVertex*>{}; }
|
virtual Array<const GeometryVertex*> GetFaceVertices(const GeometryFace& face) const { return Array<const GeometryVertex*>{}; }
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
auto & geom = dynamic_cast<OCCGeometry&>(*mesh.GetGeometry());
|
auto & geom = dynamic_cast<OCCGeometry&>(*mesh.GetGeometry());
|
||||||
|
|
||||||
auto n_edges = geom.edge_map.size();
|
auto n_edges = geom.GetNEdges();
|
||||||
constexpr int UNUSED = 0;
|
constexpr int UNUSED = 0;
|
||||||
constexpr int FORWARD = 1;
|
constexpr int FORWARD = 1;
|
||||||
constexpr int REVERSED = 2;
|
constexpr int REVERSED = 2;
|
||||||
@ -58,9 +58,7 @@ namespace netgen
|
|||||||
for(auto edge_ : GetEdges(face))
|
for(auto edge_ : GetEdges(face))
|
||||||
{
|
{
|
||||||
auto edge = TopoDS::Edge(edge_);
|
auto edge = TopoDS::Edge(edge_);
|
||||||
if(geom.edge_map.count(edge)==0)
|
auto edgenr = geom.GetEdge(edge).nr;
|
||||||
continue;
|
|
||||||
auto edgenr = geom.edge_map[edge];
|
|
||||||
auto & orientation = edge_orientation[edgenr];
|
auto & orientation = edge_orientation[edgenr];
|
||||||
double s0, s1;
|
double s0, s1;
|
||||||
auto cof = BRep_Tool::CurveOnSurface (edge, face, s0, s1);
|
auto cof = BRep_Tool::CurveOnSurface (edge, face, s0, s1);
|
||||||
|
@ -534,7 +534,7 @@ namespace netgen
|
|||||||
|
|
||||||
bool is_identified_edge = false;
|
bool is_identified_edge = false;
|
||||||
// TODO: change to use hash value
|
// TODO: change to use hash value
|
||||||
const auto& gedge = geom.GetEdge(geom.edge_map.at(e));
|
const auto& gedge = geom.GetEdge(e);
|
||||||
auto& v0 = gedge.GetStartVertex();
|
auto& v0 = gedge.GetStartVertex();
|
||||||
auto& v1 = gedge.GetEndVertex();
|
auto& v1 = gedge.GetEndVertex();
|
||||||
for(auto & ident : v0.identifications)
|
for(auto & ident : v0.identifications)
|
||||||
|
@ -156,6 +156,37 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GeometryShape & OCCGeometry :: GetShape(const TopoDS_Shape & shape) const
|
||||||
|
{
|
||||||
|
switch (shape.ShapeType())
|
||||||
|
{
|
||||||
|
case TopAbs_VERTEX:
|
||||||
|
return GetVertex(shape);
|
||||||
|
case TopAbs_EDGE:
|
||||||
|
return GetEdge(shape);
|
||||||
|
case TopAbs_FACE:
|
||||||
|
return GetFace(shape);
|
||||||
|
default:
|
||||||
|
throw Exception("unknown shape type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const GeometryVertex & OCCGeometry :: GetVertex(const TopoDS_Shape & shape) const
|
||||||
|
{
|
||||||
|
return *vertices[vmap.FindIndex(shape)-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
const GeometryEdge & OCCGeometry :: GetEdge(const TopoDS_Shape & shape) const
|
||||||
|
{
|
||||||
|
return *edges[emap.FindIndex(shape)-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
const GeometryFace & OCCGeometry :: GetFace(const TopoDS_Shape & shape) const
|
||||||
|
{
|
||||||
|
return *faces[fmap.FindIndex(shape)-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * aReader)
|
string STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * aReader)
|
||||||
{
|
{
|
||||||
const Handle(XSControl_WorkSession)& theSession = aReader->Reader().WS();
|
const Handle(XSControl_WorkSession)& theSession = aReader->Reader().WS();
|
||||||
@ -1113,20 +1144,13 @@ namespace netgen
|
|||||||
fsingular = esingular = vsingular = false;
|
fsingular = esingular = vsingular = false;
|
||||||
|
|
||||||
NetgenGeometry::Clear();
|
NetgenGeometry::Clear();
|
||||||
edge_map.clear();
|
|
||||||
vertex_map.clear();
|
|
||||||
face_map.clear();
|
|
||||||
solid_map.clear();
|
|
||||||
|
|
||||||
// Add shapes
|
// Add shapes
|
||||||
for(auto i1 : Range(1, vmap.Extent()+1))
|
for(auto i1 : Range(1, vmap.Extent()+1))
|
||||||
{
|
{
|
||||||
auto v = vmap(i1);
|
auto v = vmap(i1);
|
||||||
if(vertex_map.count(v)!=0)
|
|
||||||
continue;
|
|
||||||
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();
|
||||||
vertex_map[v] = occ_vertex->nr;
|
|
||||||
|
|
||||||
if(global_shape_properties.count(v)>0)
|
if(global_shape_properties.count(v)>0)
|
||||||
occ_vertex->properties = global_shape_properties[v];
|
occ_vertex->properties = global_shape_properties[v];
|
||||||
@ -1137,11 +1161,8 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
auto e = emap(i1);
|
auto e = emap(i1);
|
||||||
auto edge = TopoDS::Edge(e);
|
auto edge = TopoDS::Edge(e);
|
||||||
if(edge_map.count(e)!=0)
|
|
||||||
continue;
|
|
||||||
edge_map[e] = edges.Size();
|
|
||||||
auto verts = GetVertices(e);
|
auto verts = GetVertices(e);
|
||||||
auto occ_edge = make_unique<OCCEdge>(edge, *vertices[vertex_map[verts[0]]], *vertices[vertex_map[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 = global_shape_properties[e];
|
||||||
edges.Append(std::move(occ_edge));
|
edges.Append(std::move(occ_edge));
|
||||||
}
|
}
|
||||||
@ -1149,15 +1170,12 @@ namespace netgen
|
|||||||
for(auto i1 : Range(1, fmap.Extent()+1))
|
for(auto i1 : Range(1, fmap.Extent()+1))
|
||||||
{
|
{
|
||||||
auto f = fmap(i1);
|
auto f = fmap(i1);
|
||||||
if(face_map.count(f)==0)
|
|
||||||
{
|
|
||||||
|
|
||||||
auto k = faces.Size();
|
auto k = faces.Size();
|
||||||
face_map[f] = k;
|
|
||||||
auto occ_face = make_unique<OCCFace>(f);
|
auto occ_face = make_unique<OCCFace>(f);
|
||||||
|
|
||||||
for(auto e : GetEdges(f))
|
for(auto e : GetEdges(f))
|
||||||
occ_face->edges.Append( edges[edge_map[e]].get() );
|
occ_face->edges.Append( &GetEdge(e) );
|
||||||
|
|
||||||
if(global_shape_properties.count(f)>0)
|
if(global_shape_properties.count(f)>0)
|
||||||
occ_face->properties = global_shape_properties[f];
|
occ_face->properties = global_shape_properties[f];
|
||||||
@ -1166,64 +1184,59 @@ namespace netgen
|
|||||||
if(dimension==2)
|
if(dimension==2)
|
||||||
for(auto e : GetEdges(f))
|
for(auto e : GetEdges(f))
|
||||||
{
|
{
|
||||||
auto & edge = *edges[edge_map[e]];
|
auto & edge = GetEdge(e);
|
||||||
if(e.Orientation() == TopAbs_REVERSED)
|
if(e.Orientation() == TopAbs_REVERSED)
|
||||||
edge.domout = k;
|
edge.domout = k;
|
||||||
else
|
else
|
||||||
edge.domin = k;
|
edge.domin = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(auto i1 : Range(1, somap.Extent()+1))
|
for(auto i1 : Range(1, somap.Extent()+1))
|
||||||
{
|
{
|
||||||
auto s = somap(i1);
|
auto s = somap(i1);
|
||||||
int k;
|
int k = solids.Size();
|
||||||
if(solid_map.count(s)==0)
|
|
||||||
{
|
|
||||||
k = solids.Size();
|
|
||||||
solid_map[s] = k;
|
|
||||||
auto occ_solid = make_unique<OCCSolid>(s);
|
auto occ_solid = make_unique<OCCSolid>(s);
|
||||||
if(global_shape_properties.count(s)>0)
|
if(global_shape_properties.count(s)>0)
|
||||||
occ_solid->properties = global_shape_properties[s];
|
occ_solid->properties = global_shape_properties[s];
|
||||||
solids.Append(std::move(occ_solid));
|
solids.Append(std::move(occ_solid));
|
||||||
}
|
|
||||||
|
|
||||||
for(auto f : GetFaces(s))
|
for(auto f : GetFaces(s))
|
||||||
{
|
{
|
||||||
auto face_nr = face_map[f];
|
auto & face = GetFace(f);
|
||||||
auto & face = faces[face_nr];
|
if(face.domin==-1)
|
||||||
if(face->domin==-1)
|
face.domin = k;
|
||||||
face->domin = k;
|
|
||||||
else
|
else
|
||||||
face->domout = k;
|
face.domout = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add identifications
|
// Add identifications
|
||||||
auto add_identifications = [&](auto & shapes, auto & shape_map)
|
auto add_identifications = [&](auto & shapes, auto & shape_map)
|
||||||
{
|
{
|
||||||
for(auto &[shape, nr] : shape_map)
|
for(auto i1 : Range(1, shape_map.Extent()+1))
|
||||||
|
{
|
||||||
|
auto shape = shape_map(i1);
|
||||||
if(identifications.count(shape))
|
if(identifications.count(shape))
|
||||||
for(auto & ident : identifications[shape])
|
for(auto & ident : identifications[shape])
|
||||||
{
|
{
|
||||||
if(shape_map.count(ident.from)==0 || shape_map.count(ident.to)==0)
|
if(!shape_map.Contains(ident.from) || !shape_map.Contains(ident.to))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ShapeIdentification si{
|
ShapeIdentification si{
|
||||||
shapes[shape_map[ident.from]].get(),
|
&GetShape(ident.from),
|
||||||
shapes[shape_map[ident.to]].get(),
|
&GetShape(ident.to),
|
||||||
ident.trafo,
|
ident.trafo,
|
||||||
ident.type,
|
ident.type,
|
||||||
ident.name
|
ident.name
|
||||||
};
|
};
|
||||||
shapes[nr]->identifications.Append(si);
|
shapes[i1-1]->identifications.Append(si);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
add_identifications( vertices, vertex_map );
|
add_identifications( vertices, vmap );
|
||||||
add_identifications( edges, edge_map );
|
add_identifications( edges, emap );
|
||||||
add_identifications( faces, face_map );
|
add_identifications( faces, fmap );
|
||||||
|
|
||||||
bounding_box = ::netgen::GetBoundingBox( shape );
|
bounding_box = ::netgen::GetBoundingBox( shape );
|
||||||
ProcessIdentifications();
|
ProcessIdentifications();
|
||||||
@ -1312,12 +1325,12 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Array<GeometryVertex*> OCCGeometry :: GetFaceVertices(const GeometryFace& face) const
|
Array<const GeometryVertex*> OCCGeometry :: GetFaceVertices(const GeometryFace& face) const
|
||||||
{
|
{
|
||||||
Array<GeometryVertex*> verts;
|
Array<const GeometryVertex*> verts;
|
||||||
const auto& occface = dynamic_cast<const OCCFace&>(face);
|
const auto& occface = dynamic_cast<const OCCFace&>(face);
|
||||||
for(auto& vert : GetVertices(occface.Shape()))
|
for(auto& vert : GetVertices(occface.Shape()))
|
||||||
verts.Append(vertices[vertex_map.at(vert)].get());
|
verts.Append(&GetVertex(vert));
|
||||||
return move(verts);
|
return move(verts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,12 +153,10 @@ namespace netgen
|
|||||||
static std::map<TopoDS_Shape, std::vector<OCCIdentification>> identifications;
|
static std::map<TopoDS_Shape, std::vector<OCCIdentification>> identifications;
|
||||||
|
|
||||||
TopoDS_Shape shape;
|
TopoDS_Shape shape;
|
||||||
TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap; // legacy maps
|
TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
|
||||||
NgArray<bool> fsingular, esingular, vsingular;
|
NgArray<bool> fsingular, esingular, vsingular;
|
||||||
Box<3> boundingbox;
|
Box<3> boundingbox;
|
||||||
|
|
||||||
std::map<TopoDS_Shape, int> solid_map, face_map, edge_map, vertex_map;
|
|
||||||
|
|
||||||
mutable int changed;
|
mutable int changed;
|
||||||
mutable NgArray<int> facemeshstatus;
|
mutable NgArray<int> facemeshstatus;
|
||||||
|
|
||||||
@ -211,6 +209,34 @@ namespace netgen
|
|||||||
void SetOCCParameters(const OCCParameters& par)
|
void SetOCCParameters(const OCCParameters& par)
|
||||||
{ occparam = par; }
|
{ occparam = par; }
|
||||||
|
|
||||||
|
using NetgenGeometry::GetVertex;
|
||||||
|
using NetgenGeometry::GetEdge;
|
||||||
|
using NetgenGeometry::GetFace;
|
||||||
|
|
||||||
|
GeometryShape & GetShape(const TopoDS_Shape & shape)
|
||||||
|
{
|
||||||
|
return const_cast<GeometryShape&>(as_const(*this).GetShape(shape));
|
||||||
|
}
|
||||||
|
GeometryVertex & GetVertex(const TopoDS_Shape & shape)
|
||||||
|
{
|
||||||
|
return const_cast<GeometryVertex&>(as_const(*this).GetVertex(shape));
|
||||||
|
}
|
||||||
|
|
||||||
|
GeometryEdge & GetEdge(const TopoDS_Shape & shape)
|
||||||
|
{
|
||||||
|
return const_cast<GeometryEdge&>(as_const(*this).GetEdge(shape));
|
||||||
|
}
|
||||||
|
|
||||||
|
GeometryFace & GetFace(const TopoDS_Shape & shape)
|
||||||
|
{
|
||||||
|
return const_cast<GeometryFace&>(as_const(*this).GetFace(shape));
|
||||||
|
}
|
||||||
|
|
||||||
|
const GeometryShape & GetShape(const TopoDS_Shape & shape) const;
|
||||||
|
const GeometryVertex & GetVertex(const TopoDS_Shape & shape) const;
|
||||||
|
const GeometryEdge & GetEdge(const TopoDS_Shape & shape) const;
|
||||||
|
const GeometryFace & GetFace(const TopoDS_Shape & shape) const;
|
||||||
|
|
||||||
void Analyse(Mesh& mesh,
|
void Analyse(Mesh& mesh,
|
||||||
const MeshingParameters& mparam) const override;
|
const MeshingParameters& mparam) const override;
|
||||||
bool MeshFace(Mesh& mesh, const MeshingParameters& mparam,
|
bool MeshFace(Mesh& mesh, const MeshingParameters& mparam,
|
||||||
@ -267,7 +293,7 @@ namespace netgen
|
|||||||
|
|
||||||
void MakeSolid();
|
void MakeSolid();
|
||||||
|
|
||||||
Array<GeometryVertex*> GetFaceVertices(const GeometryFace& face) const override;
|
Array<const GeometryVertex*> GetFaceVertices(const GeometryFace& face) const override;
|
||||||
|
|
||||||
void HealGeometry();
|
void HealGeometry();
|
||||||
void GlueGeometry();
|
void GlueGeometry();
|
||||||
|
Loading…
Reference in New Issue
Block a user