removed references to OCC<7
This commit is contained in:
@@ -243,222 +243,16 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if OCC_VERSION_HEX < 0x070000
|
||||
static void findStyledSR (const Handle(StepVisual_StyledItem) &style,
|
||||
Handle(StepShape_ShapeRepresentation)& aSR)
|
||||
{
|
||||
// search Shape Representation for component styled item
|
||||
for (Standard_Integer j=1; j <= style->NbStyles(); j++) {
|
||||
Handle(StepVisual_PresentationStyleByContext) PSA =
|
||||
Handle(StepVisual_PresentationStyleByContext)::DownCast(style->StylesValue ( j ));
|
||||
if (PSA.IsNull())
|
||||
continue;
|
||||
StepVisual_StyleContextSelect aStyleCntxSlct = PSA->StyleContext();
|
||||
Handle(StepShape_ShapeRepresentation) aCurrentSR =
|
||||
Handle(StepShape_ShapeRepresentation)::DownCast(aStyleCntxSlct.Representation());
|
||||
if (aCurrentSR.IsNull())
|
||||
continue;
|
||||
aSR = aCurrentSR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Part::ReadColors (const Handle(XSControl_WorkSession) &WS, std::map<int, Quantity_Color>& hash_col)
|
||||
{
|
||||
#if OCC_VERSION_HEX >= 0x070000
|
||||
(void)WS;
|
||||
(void)hash_col;
|
||||
return Standard_False;
|
||||
#else
|
||||
STEPConstruct_Styles Styles (WS);
|
||||
if (!Styles.LoadStyles()) {
|
||||
#ifdef FC_DEBUG
|
||||
std::cout << "Warning: no styles are found in the model" << std::endl;
|
||||
#endif
|
||||
return Standard_False;
|
||||
}
|
||||
// searching for invisible items in the model
|
||||
Handle(TColStd_HSequenceOfTransient) aHSeqOfInvisStyle = new TColStd_HSequenceOfTransient;
|
||||
Styles.LoadInvisStyles( aHSeqOfInvisStyle );
|
||||
|
||||
// parse and search for color attributes
|
||||
Standard_Integer nb = Styles.NbStyles();
|
||||
for (Standard_Integer i=1; i <= nb; i++) {
|
||||
Handle(StepVisual_StyledItem) style = Styles.Style (i);
|
||||
if (style.IsNull()) continue;
|
||||
|
||||
Standard_Boolean IsVisible = Standard_True;
|
||||
// check the visibility of styled item.
|
||||
for (Standard_Integer si = 1; si <= aHSeqOfInvisStyle->Length(); si++) {
|
||||
if (style != aHSeqOfInvisStyle->Value(si))
|
||||
continue;
|
||||
// found that current style is invisible.
|
||||
#ifdef FC_DEBUG
|
||||
std::cout << "Warning: item No " << i << "(" << style->Item()->DynamicType()->Name() << ") is invisible" << std::endl;
|
||||
#endif
|
||||
IsVisible = Standard_False;
|
||||
break;
|
||||
}
|
||||
|
||||
Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
|
||||
// check if it is component style
|
||||
Standard_Boolean IsComponent = Standard_False;
|
||||
if (!Styles.GetColors (style, SurfCol, BoundCol, CurveCol, IsComponent) && IsVisible)
|
||||
continue;
|
||||
|
||||
// find shape
|
||||
TopoDS_Shape S = STEPConstruct::FindShape(Styles.TransientProcess(), style->Item());
|
||||
//TopAbs_ShapeEnum type = S.ShapeType();
|
||||
Standard_Boolean isSkipSHUOstyle = Standard_False;
|
||||
// take shape with real location.
|
||||
while (IsComponent) {
|
||||
// take SR of NAUO
|
||||
Handle(StepShape_ShapeRepresentation) aSR;
|
||||
findStyledSR(style, aSR);
|
||||
// search for SR along model
|
||||
if (aSR.IsNull())
|
||||
break;
|
||||
// Handle(Interface_InterfaceModel) Model = WS->Model();
|
||||
Handle(XSControl_TransferReader) TR = WS->TransferReader();
|
||||
Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
|
||||
Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings( aSR );
|
||||
Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
|
||||
for (subs.Start(); subs.More(); subs.Next()) {
|
||||
aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
|
||||
if (aSDR.IsNull())
|
||||
continue;
|
||||
StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition();
|
||||
Handle(StepRepr_ProductDefinitionShape) PDS =
|
||||
Handle(StepRepr_ProductDefinitionShape)::DownCast(aPDSselect.PropertyDefinition());
|
||||
if (PDS.IsNull())
|
||||
continue;
|
||||
StepRepr_CharacterizedDefinition aCharDef = PDS->Definition();
|
||||
|
||||
Handle(StepRepr_AssemblyComponentUsage) ACU =
|
||||
Handle(StepRepr_AssemblyComponentUsage)::DownCast(aCharDef.ProductDefinitionRelationship());
|
||||
// PTV 10.02.2003 skip styled item that refer to SHUO
|
||||
if (ACU->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) {
|
||||
isSkipSHUOstyle = Standard_True;
|
||||
break;
|
||||
}
|
||||
Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
|
||||
Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(ACU);
|
||||
if (NAUO.IsNull())
|
||||
continue;
|
||||
|
||||
TopoDS_Shape aSh;
|
||||
// PTV 10.02.2003 to find component of assembly CORRECTLY
|
||||
STEPConstruct_Tool Tool( WS );
|
||||
// Handle(Transfer_Binder) binder = TP->Find(NAUO);
|
||||
// if (binder.IsNull() || ! binder->HasResult())
|
||||
// continue;
|
||||
// aSh = TransferBRep::ShapeResult ( TP, binder );
|
||||
if (!aSh.IsNull()) {
|
||||
S = aSh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (isSkipSHUOstyle)
|
||||
continue; // skip styled item which refer to SHUO
|
||||
|
||||
if ( S.IsNull() ) {
|
||||
#ifdef FC_DEBUG
|
||||
std::cout << "Warning: item No " << i << "(" << style->Item()->DynamicType()->Name() << ") is not mapped to shape" << std::endl;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!SurfCol.IsNull()) {
|
||||
Quantity_Color col;
|
||||
Styles.DecodeColor (SurfCol, col);
|
||||
//Base::Console().Message("%d: (%.2f,%.2f,%.2f)\n",col.Name(),col.Red(),col.Green(),col.Blue());
|
||||
hash_col[S.HashCode(INT_MAX)] = col;
|
||||
}
|
||||
if (!BoundCol.IsNull()) {
|
||||
Quantity_Color col;
|
||||
Styles.DecodeColor (BoundCol, col);
|
||||
//Base::Console().Message("%d: (%.2f,%.2f,%.2f)\n",col.Name(),col.Red(),col.Green(),col.Blue());
|
||||
hash_col[S.HashCode(INT_MAX)] = col;
|
||||
}
|
||||
if (!CurveCol.IsNull()) {
|
||||
Quantity_Color col;
|
||||
Styles.DecodeColor (CurveCol, col);
|
||||
//Base::Console().Message("%d: (%.2f,%.2f,%.2f)\n",col.Name(),col.Red(),col.Green(),col.Blue());
|
||||
hash_col[S.HashCode(INT_MAX)] = col;
|
||||
}
|
||||
if (!IsVisible) {
|
||||
// sets the invisibility for shape.
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Part::ReadNames (const Handle(XSControl_WorkSession) &WS)
|
||||
{
|
||||
#if OCC_VERSION_HEX >= 0x070000
|
||||
(void)WS;
|
||||
return Standard_False;
|
||||
#else
|
||||
// get starting data
|
||||
Handle(Interface_InterfaceModel) Model = WS->Model();
|
||||
Handle(XSControl_TransferReader) TR = WS->TransferReader();
|
||||
Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
|
||||
|
||||
STEPConstruct_Tool Tool ( WS );
|
||||
|
||||
// iterate on model to find all SDRs and CDSRs
|
||||
Standard_Integer nb = Model->NbEntities();
|
||||
Handle(Standard_Type) tNAUO = STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence);
|
||||
Handle(Standard_Type) tPD = STANDARD_TYPE(StepBasic_ProductDefinition);
|
||||
Handle(TCollection_HAsciiString) name;
|
||||
for (Standard_Integer i = 1; i <= nb; i++) {
|
||||
Handle(Standard_Transient) enti = Model->Value(i);
|
||||
|
||||
// get description of NAUO
|
||||
if (enti->DynamicType() == tNAUO) {
|
||||
Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
|
||||
Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(enti);
|
||||
if (NAUO.IsNull()) continue;
|
||||
Interface_EntityIterator subs = WS->Graph().Sharings(NAUO);
|
||||
for (subs.Start(); subs.More(); subs.Next()) {
|
||||
Handle(StepRepr_ProductDefinitionShape) PDS =
|
||||
Handle(StepRepr_ProductDefinitionShape)::DownCast(subs.Value());
|
||||
if (PDS.IsNull()) continue;
|
||||
Handle(StepBasic_ProductDefinitionRelationship) PDR = PDS->Definition().ProductDefinitionRelationship();
|
||||
if (PDR.IsNull()) continue;
|
||||
if (PDR->HasDescription() &&
|
||||
PDR->Description()->Length() >0 ) name = PDR->Description();
|
||||
else if (PDR->Name()->Length() >0) name = PDR->Name();
|
||||
else name = PDR->Id();
|
||||
}
|
||||
|
||||
// find proper label
|
||||
TCollection_ExtendedString str ( name->String() );
|
||||
Base::Console().Message("Name: %s\n",name->String().ToCString());
|
||||
}
|
||||
|
||||
// for PD get name of associated product
|
||||
if (enti->DynamicType() == tPD) {
|
||||
Handle(StepBasic_ProductDefinition) PD =
|
||||
Handle(StepBasic_ProductDefinition)::DownCast(enti);
|
||||
if (PD.IsNull()) continue;
|
||||
Handle(StepBasic_Product) Prod = PD->Formation()->OfProduct();
|
||||
if (Prod->Name()->UsefullLength()>0) name = Prod->Name();
|
||||
else name = Prod->Id();
|
||||
|
||||
TCollection_ExtendedString str ( name->String() );
|
||||
Base::Console().Message("Name: %s\n",name->String().ToCString());
|
||||
}
|
||||
// set a name to the document
|
||||
//TCollection_ExtendedString str ( name->String() );
|
||||
//TDataStd_Name::Set ( L, str );
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user