mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 13:50:33 +05:00
Merge branch 'occ_read_solid_names' into 'master'
Read solid names of STEP geometries See merge request jschoeberl/netgen!297
This commit is contained in:
commit
0ee5abacb2
@ -21,6 +21,7 @@
|
|||||||
#include "XSControl_WorkSession.hxx"
|
#include "XSControl_WorkSession.hxx"
|
||||||
#include "XSControl_TransferReader.hxx"
|
#include "XSControl_TransferReader.hxx"
|
||||||
#include "StepRepr_RepresentationItem.hxx"
|
#include "StepRepr_RepresentationItem.hxx"
|
||||||
|
#include "StepBasic_ProductDefinitionRelationship.hxx"
|
||||||
|
|
||||||
#ifndef _Standard_Version_HeaderFile
|
#ifndef _Standard_Version_HeaderFile
|
||||||
#include <Standard_Version.hxx>
|
#include <Standard_Version.hxx>
|
||||||
@ -37,7 +38,7 @@
|
|||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * aReader, char * acName)
|
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();
|
||||||
const Handle(XSControl_TransferReader)& aTransferReader =
|
const Handle(XSControl_TransferReader)& aTransferReader =
|
||||||
@ -46,32 +47,28 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
|
|||||||
Handle(Standard_Transient) anEntity =
|
Handle(Standard_Transient) anEntity =
|
||||||
aTransferReader->EntityFromShapeResult(theShape, 1);
|
aTransferReader->EntityFromShapeResult(theShape, 1);
|
||||||
|
|
||||||
if (anEntity.IsNull()) {
|
if (anEntity.IsNull()) // as just mapped
|
||||||
// as just mapped
|
|
||||||
anEntity = aTransferReader->EntityFromShapeResult (theShape,-1);
|
anEntity = aTransferReader->EntityFromShapeResult (theShape,-1);
|
||||||
}
|
|
||||||
|
|
||||||
if (anEntity.IsNull()) {
|
if (anEntity.IsNull()) // as anything
|
||||||
// as anything
|
|
||||||
anEntity = aTransferReader->EntityFromShapeResult (theShape,4);
|
anEntity = aTransferReader->EntityFromShapeResult (theShape,4);
|
||||||
}
|
|
||||||
|
|
||||||
if (anEntity.IsNull()) {
|
if (anEntity.IsNull())
|
||||||
cout<<"Warning: XSInterVertex_STEPReader::ReadAttributes()\nentity not found"<<endl;
|
|
||||||
strcpy(acName, "none");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Handle(StepRepr_RepresentationItem) aReprItem;
|
cout<<"Warning: cannot get entity from shape" <<endl;
|
||||||
aReprItem =
|
return "none";
|
||||||
Handle(StepRepr_RepresentationItem)::DownCast(anEntity);
|
}
|
||||||
|
|
||||||
if (aReprItem.IsNull()) {
|
auto aReprItem = Handle(StepRepr_RepresentationItem)::DownCast(anEntity);
|
||||||
cout<<"Error: STEPReader::ReadAttributes():\nStepRepr_RepresentationItem Is NULL"<<endl;
|
if(!aReprItem.IsNull())
|
||||||
}
|
return aReprItem->Name()->ToCString();;
|
||||||
else
|
|
||||||
strcpy(acName, aReprItem->Name()->ToCString());
|
auto bReprItem = Handle(StepBasic_ProductDefinitionRelationship)::DownCast(anEntity);
|
||||||
}
|
if (!bReprItem.IsNull())
|
||||||
|
return bReprItem->Description()->ToCString();
|
||||||
|
|
||||||
|
cout<<"Warning: unknown entity type " << anEntity->DynamicType() << endl;
|
||||||
|
return "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCCGeometry :: Analyse(Mesh& mesh,
|
void OCCGeometry :: Analyse(Mesh& mesh,
|
||||||
@ -1380,24 +1377,29 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
|
|||||||
|
|
||||||
occgeo->CalcBoundingBox();
|
occgeo->CalcBoundingBox();
|
||||||
PrintContents (occgeo);
|
PrintContents (occgeo);
|
||||||
char * name = new char[50];
|
string name;
|
||||||
//string name;
|
|
||||||
STEP_GetEntityName(occgeo->shape,&reader,name);
|
|
||||||
occgeo->snames.Append(name);
|
|
||||||
TopExp_Explorer exp0,exp1;
|
TopExp_Explorer exp0,exp1;
|
||||||
|
|
||||||
timer_getnames.Start();
|
timer_getnames.Start();
|
||||||
|
for (exp0.Init(occgeo->shape, TopAbs_SOLID); exp0.More(); exp0.Next())
|
||||||
|
{
|
||||||
|
TopoDS_Solid solid = TopoDS::Solid(exp0.Current());
|
||||||
|
name = STEP_GetEntityName(solid,&reader);
|
||||||
|
if (name == "")
|
||||||
|
name = string("domain_") + ToString(occgeo->snames.Size());
|
||||||
|
occgeo->snames.Append(name);
|
||||||
|
}
|
||||||
for (exp0.Init(occgeo->shape, TopAbs_FACE); exp0.More(); exp0.Next())
|
for (exp0.Init(occgeo->shape, TopAbs_FACE); exp0.More(); exp0.Next())
|
||||||
{
|
{
|
||||||
TopoDS_Face face = TopoDS::Face(exp0.Current());
|
TopoDS_Face face = TopoDS::Face(exp0.Current());
|
||||||
STEP_GetEntityName(face,&reader,name);
|
name = STEP_GetEntityName(face,&reader);
|
||||||
if (name == string(""))
|
if (name == "")
|
||||||
snprintf(name, 50, "bc_%zu", occgeo->fnames.Size());
|
name = string("bc_") + ToString(occgeo->fnames.Size());
|
||||||
occgeo->fnames.Append(name);
|
occgeo->fnames.Append(name);
|
||||||
// for (exp1.Init(face, TopAbs_EDGE); exp1.More(); exp1.Next())
|
// for (exp1.Init(face, TopAbs_EDGE); exp1.More(); exp1.Next())
|
||||||
// {
|
// {
|
||||||
// TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
|
// TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
|
||||||
// STEP_GetEntityName(edge,&reader,name);
|
// name = STEP_GetEntityName(edge,&reader);
|
||||||
// occgeo->enames.Append(name);
|
// occgeo->enames.Append(name);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user