#include <STEPCAFControl_Reader.hxx>
#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Geom_CartesianPoint.hxx>
+#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Interface_EntityIterator.hxx>
#include <Interface_InterfaceModel.hxx>
#include <STEPControl_Reader.hxx>
#include <StepGeom_GeometricRepresentationItem.hxx>
#include <StepGeom_Axis2Placement3d.hxx>
+#include <StepGeom_Curve.hxx>
#include <StepGeom_Direction.hxx>
#include <StepDimTol_AngularityTolerance.hxx>
#include <StepDimTol_CircularRunoutTolerance.hxx>
// Update assembly compounds
STool->UpdateAssemblies();
-
return Standard_True;
}
return;
}
+//=======================================================================
+//function : computePMIReferensePosition
+//purpose : compute position of shape contains in the shapeAspect
+//=======================================================================
+Standard_Boolean computePMIReferensePosition(const Handle(StepRepr_ShapeAspect)& theReference,
+ const Interface_Graph& theGraph,
+ gp_Pnt& thePosition)
+{
+ if (theReference.IsNull())
+ return Standard_False;
+ Handle(StepAP242_GeometricItemSpecificUsage) aGISU = NULL;
+ for (Interface_EntityIterator anIt = theGraph.Sharings(theReference); aGISU.IsNull() && anIt.More(); anIt.Next())
+ {
+ aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIt.Value());
+ }
+ if (aGISU.IsNull() || aGISU->NbIdentifiedItem() == 0)
+ return Standard_False;
+ const Handle(StepRepr_RepresentationItem)& anItem = aGISU->IdentifiedItem()->Value(1);
+ if (anItem->IsKind(STANDARD_TYPE(StepGeom_CartesianPoint)))
+ {
+ Handle(StepGeom_CartesianPoint) aPoint = Handle(StepGeom_CartesianPoint)::DownCast(anItem);
+ thePosition.SetX(aPoint->CoordinatesValue(1));
+ thePosition.SetY(aPoint->CoordinatesValue(2));
+ thePosition.SetZ(aPoint->CoordinatesValue(3));
+ return Standard_True;
+ }
+ else if (anItem->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
+ {
+ Handle(StepGeom_Axis2Placement3d) anA2P3D = Handle(StepGeom_Axis2Placement3d)::DownCast(anItem);
+ if (!anA2P3D->Location().IsNull())
+ {
+ thePosition.SetX(anA2P3D->Location()->CoordinatesValue(1));
+ thePosition.SetY(anA2P3D->Location()->CoordinatesValue(2));
+ thePosition.SetZ(anA2P3D->Location()->CoordinatesValue(3));
+ return Standard_True;
+ }
+ }
+ return Standard_False;
+}
+
//=======================================================================
//function : readConnectionPoints
//purpose : read connection points for given dimension
aFact = UnitsMethods::LengthFactor();
}
- if (theGDT->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
- // retrieve derived geometry
+ if (theGDT->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)))
+ {
Handle(StepShape_DimensionalSize) aDim = Handle(StepShape_DimensionalSize)::DownCast(theGDT);
- Handle(StepRepr_DerivedShapeAspect) aDSA = Handle(StepRepr_DerivedShapeAspect)::DownCast(aDim->AppliesTo());
- if (aDSA.IsNull())
- return;
- Handle(StepAP242_GeometricItemSpecificUsage) aGISU = NULL;
- for (Interface_EntityIterator anIt = aGraph.Sharings(aDSA); aGISU.IsNull() && anIt.More(); anIt.Next()) {
- aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIt.Value());
- }
- if (aGISU.IsNull() || aGISU->NbIdentifiedItem() == 0)
- return;
- Handle(StepGeom_CartesianPoint) aPoint = Handle(StepGeom_CartesianPoint)::DownCast(aGISU->IdentifiedItem()->Value(1));
- if (aPoint.IsNull()) {
- // try Axis2Placement3d.location instead of CartesianPoint
- Handle(StepGeom_Axis2Placement3d) anA2P3D =
- Handle(StepGeom_Axis2Placement3d)::DownCast(aGISU->IdentifiedItem()->Value(1));
- if (anA2P3D.IsNull())
- return;
- aPoint = anA2P3D->Location();
+ gp_Pnt aPnt;
+ if (computePMIReferensePosition(aDim->AppliesTo(), aGraph, aPnt))
+ {
+ // set connection point to object
+ aPnt.SetXYZ(aPnt.XYZ() * aFact);
+ theDimObject->SetPoint(aPnt);
}
-
- // set connection point to object
- gp_Pnt aPnt(aPoint->CoordinatesValue(1) * aFact, aPoint->CoordinatesValue(2) * aFact, aPoint->CoordinatesValue(3) * aFact);
- theDimObject->SetPoint(aPnt);
}
- else if (theGDT->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) {
- // retrieve derived geometry
+ else if (theGDT->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)))
+ {
Handle(StepShape_DimensionalLocation) aDim = Handle(StepShape_DimensionalLocation)::DownCast(theGDT);
- Handle(StepRepr_DerivedShapeAspect) aDSA1 = Handle(StepRepr_DerivedShapeAspect)::DownCast(aDim->RelatingShapeAspect());
- Handle(StepRepr_DerivedShapeAspect) aDSA2 = Handle(StepRepr_DerivedShapeAspect)::DownCast(aDim->RelatedShapeAspect());
- if (aDSA1.IsNull() && aDSA2.IsNull())
- return;
- Handle(StepAP242_GeometricItemSpecificUsage) aGISU1 = NULL;
- Handle(StepAP242_GeometricItemSpecificUsage) aGISU2 = NULL;
- if (!aDSA1.IsNull()) {
- for (Interface_EntityIterator anIt = aGraph.Sharings(aDSA1); aGISU1.IsNull() && anIt.More(); anIt.Next()) {
- aGISU1 = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIt.Value());
- }
- }
- if (!aDSA2.IsNull()) {
- for (Interface_EntityIterator anIt = aGraph.Sharings(aDSA2); aGISU2.IsNull() && anIt.More(); anIt.Next()) {
- aGISU2 = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIt.Value());
- }
- }
- // first point
- if (!aGISU1.IsNull() && aGISU1->NbIdentifiedItem() > 0) {
- Handle(StepGeom_CartesianPoint) aPoint = Handle(StepGeom_CartesianPoint)::DownCast(aGISU1->IdentifiedItem()->Value(1));
- if (aPoint.IsNull()) {
- // try Axis2Placement3d.location instead of CartesianPoint
- Handle(StepGeom_Axis2Placement3d) anA2P3D =
- Handle(StepGeom_Axis2Placement3d)::DownCast(aGISU1->IdentifiedItem()->Value(1));
- if (!anA2P3D.IsNull())
- aPoint = anA2P3D->Location();
- }
- if (!aPoint.IsNull()) {
- // set connection point to object
- gp_Pnt aPnt(aPoint->CoordinatesValue(1) * aFact, aPoint->CoordinatesValue(2) * aFact, aPoint->CoordinatesValue(3) * aFact);
- theDimObject->SetPoint(aPnt);
- }
+ gp_Pnt aPnt;
+ if (computePMIReferensePosition(aDim->RelatingShapeAspect(), aGraph, aPnt))
+ {
+ // set connection point to object
+ aPnt.SetXYZ(aPnt.XYZ() * aFact);
+ theDimObject->SetPoint(aPnt);
}
- // second point
- if (!aGISU2.IsNull() && aGISU2->NbIdentifiedItem() > 0) {
- Handle(StepGeom_CartesianPoint) aPoint = Handle(StepGeom_CartesianPoint)::DownCast(aGISU2->IdentifiedItem()->Value(1));
- if (aPoint.IsNull()) {
- // try Axis2Placement3d.location instead of CartesianPoint
- Handle(StepGeom_Axis2Placement3d) anA2P3D =
- Handle(StepGeom_Axis2Placement3d)::DownCast(aGISU2->IdentifiedItem()->Value(1));
- if (!anA2P3D.IsNull())
- aPoint = anA2P3D->Location();
- }
- if (!aPoint.IsNull()) {
- // set connection point to object
- gp_Pnt aPnt(aPoint->CoordinatesValue(1) * aFact, aPoint->CoordinatesValue(2) * aFact, aPoint->CoordinatesValue(3) * aFact);
- theDimObject->SetPoint2(aPnt);
- }
+ if (computePMIReferensePosition(aDim->RelatedShapeAspect(), aGraph, aPnt))
+ {
+ // set connection point to object
+ aPnt.SetXYZ(aPnt.XYZ() * aFact);
+ theDimObject->SetPoint2(aPnt);
}
}
}
NCollection_Sequence<Handle(Standard_Transient)> aSeqRI1, aSeqRI2;
// Collect all Shape_Aspect entities
- Interface_EntityIterator anIter = aGraph.Shareds(theEnt);
- for (anIter.Start(); anIter.More(); anIter.Next()) {
+ for (Interface_EntityIterator anIter = aGraph.Shareds(theEnt);
+ anIter.More(); anIter.Next())
+ {
Handle(Standard_Transient) anAtr = anIter.Value();
NCollection_Sequence<Handle(StepRepr_ShapeAspect)> aSAs;
if (anAtr->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape)))
TDF_LabelSequence aShLS1, aShLS2;
// Collect shapes
- for (Standard_Integer i = aSeqRI1.Lower(); i <= aSeqRI1.Upper();i++)
+ for (NCollection_Sequence<Handle(Standard_Transient)>::Iterator anIter(aSeqRI1);
+ anIter.More(); anIter.Next())
{
- Standard_Integer anIndex = FindShapeIndexForDGT(aSeqRI1.Value(i), theWS);
- TopoDS_Shape aSh;
- if (anIndex > 0) {
- Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
- aSh = TransferBRep::ShapeResult(aBinder);
- }
- if (!aSh.IsNull())
- {
- TDF_Label aShL;
- aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
- if (aShL.IsNull() && aSh.ShapeType() == TopAbs_WIRE)
- {
- TopExp_Explorer ex(aSh, TopAbs_EDGE, TopAbs_SHAPE);
- while (ex.More())
- {
- TDF_Label edgeL;
- aSTool->Search(ex.Current(), edgeL, Standard_True, Standard_True, Standard_True);
- if (!edgeL.IsNull())
- aShLS1.Append(edgeL);
- ex.Next();
- }
- }
- if (!aShL.IsNull())
- aShLS1.Append(aShL);
- }
+ findReferenceGeometry(anIter.Value(), aSTool, aShLS1);
}
- if (!aSeqRI2.IsEmpty())
+ for (NCollection_Sequence<Handle(Standard_Transient)>::Iterator anIter(aSeqRI2);
+ anIter.More(); anIter.Next())
{
- //for dimensional location
- for (Standard_Integer i = aSeqRI2.Lower(); i <= aSeqRI2.Upper();i++)
- {
- Standard_Integer anIndex = FindShapeIndexForDGT(aSeqRI2.Value(i), theWS);
- TopoDS_Shape aSh;
- if (anIndex > 0) {
- Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
- aSh = TransferBRep::ShapeResult(aBinder);
- }
- if (!aSh.IsNull())
- {
- TDF_Label aShL;
- aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
- if (aShL.IsNull() && aSh.ShapeType() == TopAbs_WIRE)
- {
- TopExp_Explorer ex(aSh, TopAbs_EDGE, TopAbs_SHAPE);
- while (ex.More())
- {
- TDF_Label edgeL;
- aSTool->Search(ex.Current(), edgeL, Standard_True, Standard_True, Standard_True);
- if (!edgeL.IsNull())
- aShLS2.Append(edgeL);
- ex.Next();
- }
- }
- if (!aShL.IsNull())
- aShLS2.Append(aShL);
- }
- }
+ findReferenceGeometry(anIter.Value(), aSTool, aShLS2);
}
if (!aShLS1.IsEmpty())
return aGDTL;
}
+//=======================================================================
+//function : findReferenceGeometry
+//purpose :
+//=======================================================================
+Standard_Boolean STEPCAFControl_Reader::findReferenceGeometry(const Handle(Standard_Transient)& theShapeStart,
+ const Handle(XCAFDoc_ShapeTool)& theShTool,
+ TDF_LabelSequence& theShLabelSeq)
+{
+ const Handle(XSControl_TransferReader)& aTR = myReader.WS()->TransferReader();
+ const Handle(Transfer_TransientProcess)& aTP = aTR->TransientProcess();
+ TopoDS_Shape aSh = TransferBRep::ShapeResult(aTP, theShapeStart);
+ if (!aSh.IsNull())
+ {
+ TDF_Label aShL;
+ theShTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
+ if (aShL.IsNull() && aSh.ShapeType() == TopAbs_WIRE)
+ {
+ for (TopExp_Explorer anExp(aSh, TopAbs_EDGE, TopAbs_SHAPE);
+ anExp.More(); anExp.Next())
+ {
+ TDF_Label anEdgeL;
+ theShTool->Search(anExp.Current(), anEdgeL, Standard_True, Standard_True, Standard_True);
+ if (!anEdgeL.IsNull())
+ {
+ theShLabelSeq.Append(anEdgeL);
+ }
+ }
+ }
+ if (!aShL.IsNull())
+ {
+ theShLabelSeq.Append(aShL);
+ return Standard_True;
+ }
+ }
+ TDF_Label aFindResultL;
+ if (myGDTMap.Find(theShapeStart, aFindResultL))
+ {
+ theShLabelSeq.Append(aFindResultL);
+ return Standard_True;
+ }
+ const Handle(StepGeom_GeometricRepresentationItem)& aGeomItem =
+ Handle(StepGeom_GeometricRepresentationItem)::DownCast(theShapeStart);
+ if (aGeomItem.IsNull())
+ {
+ return Standard_False;
+ }
+ if (theShapeStart->IsKind(STANDARD_TYPE(StepGeom_Curve)))
+ {
+ const Handle(StepGeom_Curve)& aStepCurve = Handle(StepGeom_Curve)::DownCast(theShapeStart);
+ Handle(Geom_Curve) aCurve = StepToGeom::MakeCurve(aStepCurve);
+ if (aCurve.IsNull())
+ {
+ return Standard_False;
+ }
+ BRepBuilderAPI_MakeEdge aMaker;
+ if (aCurve->IsKind(STANDARD_TYPE(Geom_Line)))
+ {
+ const Standard_Real aScale = UnitsMethods::LengthFactor();
+ aMaker.Init(aCurve, 0, 1. * aScale);
+ }
+ else
+ {
+ aMaker.Init(aCurve);
+ }
+ if (aMaker.IsDone())
+ {
+ aSh = aMaker.Shape();
+ }
+ }
+ else if (theShapeStart->IsKind(STANDARD_TYPE(StepGeom_Surface)))
+ {
+ const Handle(StepGeom_Surface)& aStepSurface = Handle(StepGeom_Surface)::DownCast(theShapeStart);
+ Handle(Geom_Surface) aSurface = StepToGeom::MakeSurface(aStepSurface);
+ if (aSurface.IsNull())
+ {
+ return Standard_False;
+ }
+ BRepBuilderAPI_MakeFace aMaker;
+ if (aSurface->IsKind(STANDARD_TYPE(Geom_Plane)))
+ {
+ const Standard_Real aScale = UnitsMethods::LengthFactor();
+ aMaker.Init(aSurface, 0., 1. * aScale, 0., 1. * aScale, Precision::Confusion());
+ }
+ else
+ {
+ aMaker.Init(aSurface, Standard_True, Precision::Confusion());
+ }
+ if (aMaker.IsDone())
+ {
+ aSh = aMaker.Shape();
+ }
+ }
+ if (aSh.IsNull())
+ {
+ return Standard_False;
+ }
+ if (mySupplementalLabel.IsNull())
+ {
+ mySupplementalLabel = theShTool->NewShape();
+ TDataStd_Name::Set(mySupplementalLabel, "Supplemental Geometry");
+ TDataStd_UAttribute::Set(mySupplementalLabel, XCAFDoc::SupplementalContainerGUID());
+ TDataStd_UAttribute::Set(mySupplementalLabel, XCAFDoc::InvisibleGUID());
+ }
+ TDF_Label aSupGeomLabel = theShTool->AddComponent(mySupplementalLabel, aSh);
+ if (aSupGeomLabel.IsNull())
+ {
+ return Standard_False;
+ }
+ TDataStd_UAttribute::Set(aSupGeomLabel, XCAFDoc::SupplementalGeometryGUID());
+
+ if (!aGeomItem->Name().IsNull())
+ {
+ TDataStd_Name::Set(aSupGeomLabel, aGeomItem->Name()->String());
+ TDF_Label aReferredShapeL;
+ theShTool->GetReferredShape(aSupGeomLabel, aReferredShapeL);
+ TDataStd_Name::Set(aReferredShapeL, aGeomItem->Name()->String());
+ TDataStd_UAttribute::Set(aReferredShapeL, XCAFDoc::SupplementalGeometryGUID());
+ }
+ TDF_Label aRefL;
+ const Interface_Graph& aGraph = aTP->Graph();
+ for (Interface_EntityIterator anIter(aGraph.Sharings(theShapeStart));
+ anIter.More() && aRefL.IsNull(); anIter.Next())
+ {
+ Handle(StepAP242_GeometricItemSpecificUsage) aPGISU =
+ Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIter.Value());
+ if (aPGISU.IsNull())
+ {
+ continue;
+ }
+ Handle(StepRepr_ShapeAspect) aShAspect = aPGISU->Definition().ShapeAspect();
+ if (aShAspect.IsNull())
+ {
+ continue;
+ }
+ Handle(StepRepr_ProductDefinitionShape) aRefPDS = aShAspect->OfShape();
+ if (aRefPDS.IsNull())
+ {
+ continue;
+ }
+ TopoDS_Shape aRefSh = TransferBRep::ShapeResult(aTP, aRefPDS->Definition().Value());
+ theShTool->Search(aRefSh, aRefL, Standard_True, Standard_True, Standard_False);
+ }
+
+ if (aRefL.IsNull())
+ {
+ TDF_LabelSequence aFreeShapes;
+ theShTool->GetFreeShapes(aFreeShapes);
+ for(TDF_LabelSequence::Iterator anIter(aFreeShapes); anIter.More() && aRefL.IsNull(); anIter.Next())
+ {
+ const TDF_Label aLabel = anIter.Value();
+ Handle(TDataStd_UAttribute) aSupGeomAttr;
+ if (aLabel.FindAttribute(XCAFDoc::SupplementalContainerGUID(), aSupGeomAttr))
+ {
+ continue;
+ }
+ TopoDS_Shape aTmpShape = theShTool->GetShape(aLabel);
+ if (!aTmpShape.IsNull())
+ {
+ aRefL = aLabel;
+ }
+ }
+ }
+ if (aRefL.IsNull())
+ {
+ return Standard_False;
+ }
+
+ // set reference
+ Handle(TDataStd_TreeNode) aMainNode = TDataStd_TreeNode::Set(aRefL, XCAFDoc::SupplementalRefGUID());
+ Handle(TDataStd_TreeNode) aRefNode = TDataStd_TreeNode::Set(aSupGeomLabel, XCAFDoc::SupplementalRefGUID());
+ aRefNode->Remove(); // abv: fix against bug in TreeNode::Append()
+ aMainNode->Append(aRefNode);
+ myGDTMap.Bind(theShapeStart, aSupGeomLabel);
+ theShLabelSeq.Append(aSupGeomLabel);
+ return Standard_True;
+}
+
//=======================================================================
//function : convertAngleValue
//purpose : auxilary
const Handle(TDocStd_Document)& theDoc,
const Handle(XSControl_WorkSession)& theWS);
+ //! Finds reference geometry or create supplemental geometry label
+ //! @param[in] theShapeStart step entity to get reference
+ //! @param[in] theShTool tool to work with shape labels
+ //! @param[out] theShLabelSeq container to put reference label
+ //! @return TRUE if a reference is found or supplemental geometry is added
+ Standard_Boolean findReferenceGeometry(const Handle(Standard_Transient)& theShapeStart,
+ const Handle(XCAFDoc_ShapeTool)& theShTool,
+ TDF_LabelSequence& theShLabelSeq);
STEPControl_Reader myReader;
NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
+ TDF_Label mySupplementalLabel;
Standard_Boolean myColorMode;
Standard_Boolean myNameMode;
Standard_Boolean myLayerMode;
#include <STEPCAFControl_Writer.hxx>
#include <BRep_Builder.hxx>
+#include <GeomToStep_MakeSurface.hxx>
+#include <GeomToStep_MakeCurve.hxx>
#include <GeomToStep_MakeAxis2Placement3d.hxx>
#include <GeomToStep_MakeCartesianPoint.hxx>
#include <HeaderSection_FileSchema.hxx>
#include <StepRepr_CompositeShapeAspect.hxx>
#include <StepRepr_ConstructiveGeometryRepresentation.hxx>
#include <StepRepr_ConstructiveGeometryRepresentationRelationship.hxx>
+#include <StepGeom_Curve.hxx>
#include <StepRepr_DerivedShapeAspect.hxx>
#include <StepRepr_DescriptiveRepresentationItem.hxx>
#include <StepRepr_FeatureForDatumTargetRelationship.hxx>
#include <TDF_LabelSequence.hxx>
#include <TDF_Tool.hxx>
#include <TDocStd_Document.hxx>
+#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
TDF_Label L = labels.Value(i);
if ( myLabels.IsBound ( L ) ) continue; // already processed
+ Handle(TDataStd_UAttribute) aSupGeomAttr;
+ if (L.FindAttribute(XCAFDoc::SupplementalContainerGUID(), aSupGeomAttr))
+ {
+ continue;
+ }
+
TopoDS_Shape shape = XCAFDoc_ShapeTool::GetShape ( L );
if ( shape.IsNull() ) continue;
return aSA;
}
+//=======================================================================
+//function : WriteSupplementalGeometry
+//purpose :
+//=======================================================================
+Handle(StepRepr_ShapeAspect) WriteSupplementalGeometry(const Handle(XSControl_WorkSession)& WS,
+ const Handle(StepRepr_ConstructiveGeometryRepresentation)& theCGRepr,
+ const TDF_Label& theLabel,
+ const TopoDS_Shape& theShape,
+ Handle(StepRepr_RepresentationContext)& theRC,
+ Handle(StepAP242_GeometricItemSpecificUsage)& theGISU,
+ NCollection_Vector<Handle(StepGeom_GeometricRepresentationItem)>& theGeomItems)
+{
+ Handle(StepRepr_ShapeAspect) aResSA;
+ // Get working data
+ const Handle(Interface_InterfaceModel)& aModel = WS->Model();
+ const Handle(XSControl_TransferWriter)& aTW = WS->TransferWriter();
+ const Handle(Transfer_FinderProcess)& aFP = aTW->FinderProcess();
+ const Handle(Interface_HGraph) aHGraph = WS->HGraph();
+ if (aHGraph.IsNull())
+ {
+ return aResSA;
+ }
+ Interface_Graph aGraph = aHGraph->Graph();
+
+ // Shape_Aspect
+ Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString();
+ Handle(TDataStd_Name) aNameAttr;
+ if (theLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttr))
+ {
+ aName = new TCollection_HAsciiString(TCollection_AsciiString(aNameAttr->Get()));
+ }
+ Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString();
+
+ Handle(TDataStd_TreeNode) aRefNode;
+ if (!theLabel.FindAttribute(XCAFDoc::SupplementalRefGUID(), aRefNode)
+ || aRefNode->Father().IsNull() || aRefNode->Father()->Label().IsNull())
+ {
+ return aResSA;
+ }
+ TopoDS_Shape aMainShape = XCAFDoc_ShapeTool::GetShape(aRefNode->Father()->Label());
+ TopLoc_Location aLoc;
+ TColStd_SequenceOfTransient aSeqRI;
+ FindEntities(aFP, aMainShape, aLoc, aSeqRI);
+ if (aSeqRI.Length() <= 0)
+ {
+ aFP->Messenger()->SendInfo() << "Warning: Cannot find RI for " << aMainShape.TShape()->DynamicType()->Name() << std::endl;
+ return aResSA;
+ }
+
+ Handle(StepRepr_ProductDefinitionShape) aPDS;
+ Handle(StepRepr_RepresentationContext) aRC;
+ Handle(Standard_Transient) anEnt = aSeqRI.Value(1);
+ aPDS = FindPDS(aGraph, anEnt, aRC);
+ if (aPDS.IsNull())
+ return aResSA;
+
+ theRC = aRC;
+
+ Handle(StepGeom_GeometricRepresentationItem) anIdentifiedItem;
+ if (theShape.ShapeType() == TopAbs_FACE)
+ {
+ const TopoDS_Face& aFace = TopoDS::Face(theShape);
+ const Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+ GeomToStep_MakeSurface aMaker(aSurf);
+ if (aMaker.IsDone())
+ {
+ anIdentifiedItem = aMaker.Value();
+ }
+ }
+ else if (theShape.ShapeType() == TopAbs_EDGE)
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge(theShape);
+ Standard_Real aTmpFirst, aTmpLast;
+ const Handle(Geom_Curve) aCurv = BRep_Tool::Curve(anEdge, aTmpFirst, aTmpLast);
+ GeomToStep_MakeCurve aMaker(aCurv);
+ if (aMaker.IsDone())
+ {
+ anIdentifiedItem = aMaker.Value();
+ }
+ }
+ if (anIdentifiedItem.IsNull())
+ {
+ return aResSA;
+ }
+ aResSA = new StepRepr_ShapeAspect();
+ aResSA->Init(aName, aDescription, aPDS, StepData_LTrue);
+ // Geometric_Item_Specific_Usage
+ Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage();
+ StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
+ aDefinition.SetValue(aResSA);
+ Handle(StepRepr_HArray1OfRepresentationItem) anReprItems = new StepRepr_HArray1OfRepresentationItem(1, 1);
+
+ anIdentifiedItem->SetName(aName);
+ theGISU = aGISU;
+ anReprItems->SetValue(1, anIdentifiedItem);
+ theGeomItems.Append(anIdentifiedItem);
+
+ // Set entities to model
+ aGISU->Init(aName, aDescription, aDefinition, theCGRepr, anReprItems);
+ aModel->AddWithRefs(aResSA);
+ aModel->AddWithRefs(aGISU);
+ return aResSA;
+}
+
//=======================================================================
//function : WritePresentation
//purpose : auxiliary (write annotation plane and presentation)
const Handle(StepRepr_ConstructiveGeometryRepresentation) theRepr,
Handle(StepRepr_ShapeAspect)& theFirstSA,
Handle(StepRepr_ShapeAspect)& theSecondSA,
- NCollection_Vector<Handle(StepGeom_CartesianPoint)>& thePnts)
+ NCollection_Vector<Handle(StepGeom_GeometricRepresentationItem)>& theGeoms)
{
const Handle(Interface_InterfaceModel) &aModel = WS->Model();
// First point
if (theObject->HasPoint()) {
GeomToStep_MakeCartesianPoint aPointMaker(theObject->GetPoint());
Handle(StepGeom_CartesianPoint) aPoint = aPointMaker.Value();
- thePnts.Append(aPoint);
+ theGeoms.Append(aPoint);
Handle(StepRepr_DerivedShapeAspect) aDSA = new StepRepr_DerivedShapeAspect();
aDSA->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), theFirstSA->OfShape(), StepData_LFalse);
Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage();
if (theObject->HasPoint2()) {
GeomToStep_MakeCartesianPoint aPointMaker(theObject->GetPoint2());
Handle(StepGeom_CartesianPoint) aPoint = aPointMaker.Value();
- thePnts.Append(aPoint);
+ theGeoms.Append(aPoint);
Handle(StepRepr_DerivedShapeAspect) aDSA = new StepRepr_DerivedShapeAspect();
aDSA->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), theFirstSA->OfShape(), StepData_LFalse);
Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage();
aLMWU->Init(aValueMember, aUnit);
Model->AddWithRefs(aLMWU);
+ // Auxiliary entities for derived geometry
+ Handle(StepRepr_ConstructiveGeometryRepresentation) aCGRepr =
+ new StepRepr_ConstructiveGeometryRepresentation();
+ Handle(StepRepr_ConstructiveGeometryRepresentationRelationship) aCGReprRel =
+ new StepRepr_ConstructiveGeometryRepresentationRelationship();
+ NCollection_Vector<Handle(StepGeom_GeometricRepresentationItem)> aConnectionGeometry;
+
// Geometric_Tolerance target
Handle(StepRepr_ShapeAspect) aMainSA;
Handle(StepRepr_RepresentationContext) dummyRC;
Handle(StepAP242_GeometricItemSpecificUsage) dummyGISU;
if (theShapeSeqL.Length() == 1) {
- TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(theShapeSeqL.Value(1));
- aMainSA = WriteShapeAspect(WS, theGeomTolL, aShape, dummyRC, dummyGISU);
+ const TDF_Label& aShLabel = theShapeSeqL.Value(1);
+ Handle(TDataStd_UAttribute) aSupAttr;
+ TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aShLabel);
+ if (aShLabel.FindAttribute(XCAFDoc::SupplementalGeometryGUID(), aSupAttr))
+ {
+ aMainSA = WriteSupplementalGeometry(WS, aCGRepr, aShLabel, aShape, dummyRC, dummyGISU, aConnectionGeometry);
+ }
+ else
+ {
+ aMainSA = WriteShapeAspect(WS, theGeomTolL, aShape, dummyRC, dummyGISU);
+ }
Model->AddWithRefs(aMainSA);
}
else {
Handle(StepRepr_CompositeShapeAspect) aCSA;
for (Standard_Integer i = 1; i <= theShapeSeqL.Length(); i++) {
- TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(theShapeSeqL.Value(i));
- Handle(StepRepr_ShapeAspect) aSA = WriteShapeAspect(WS, theGeomTolL, aShape, dummyRC, dummyGISU);
+ const TDF_Label& aShLabel = theShapeSeqL.Value(i);
+ Handle(TDataStd_UAttribute) aSupAttr;
+ TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aShLabel);
+ Handle(StepRepr_ShapeAspect) aSA;
+ if (aShLabel.FindAttribute(XCAFDoc::SupplementalGeometryGUID(), aSupAttr))
+ {
+ aSA = WriteSupplementalGeometry(WS, aCGRepr, aShLabel, aShape, dummyRC, dummyGISU, aConnectionGeometry);
+ }
+ else
+ {
+ aSA = WriteShapeAspect(WS, theGeomTolL, aShape, dummyRC, dummyGISU);
+ }
if (aSA.IsNull())
continue;
if (aCSA.IsNull()) {
}
aMainSA = aCSA;
}
+ // Write Derived geometry
+ if (aConnectionGeometry.Length() > 0)
+ {
+ Handle(StepRepr_HArray1OfRepresentationItem) anItems = new StepRepr_HArray1OfRepresentationItem(1, aConnectionGeometry.Length());
+ for (Standard_Integer i = 0; i < aConnectionGeometry.Length(); i++)
+ anItems->SetValue(i + 1, aConnectionGeometry(i));
+ aCGRepr->Init(new TCollection_HAsciiString(), anItems, dummyRC);
+ aCGReprRel->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), dummyGISU->UsedRepresentation(), aCGRepr);
+ Model->AddWithRefs(aCGReprRel);
+ }
+
StepDimTol_GeometricToleranceTarget aGTTarget;
aGTTarget.SetValue(aMainSA);
new StepRepr_ConstructiveGeometryRepresentation();
Handle(StepRepr_ConstructiveGeometryRepresentationRelationship) aCGReprRel =
new StepRepr_ConstructiveGeometryRepresentationRelationship();
- NCollection_Vector<Handle(StepGeom_CartesianPoint)> aConnectionPnts;
+ NCollection_Vector<Handle(StepGeom_GeometricRepresentationItem)> aConnectionGeometry;
Handle(StepRepr_RepresentationContext) dummyRC;
Handle(StepAP242_GeometricItemSpecificUsage) dummyGISU;
for (Standard_Integer i = 1; i <= aDGTLabels.Length(); i++) {
// Write links with shapes
Handle(StepRepr_ShapeAspect) aFirstSA, aSecondSA;
if (aFirstShapeL.Length() == 1) {
- TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aFirstShapeL.Value(1));
- aFirstSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+ const TDF_Label& aShLabel = aFirstShapeL.Value(1);
+ TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aShLabel);
+ Handle(TDataStd_UAttribute) aSupAttr;
+ if (aShLabel.FindAttribute(XCAFDoc::SupplementalGeometryGUID(), aSupAttr))
+ {
+ aFirstSA = WriteSupplementalGeometry(WS,aCGRepr, aShLabel, aShape, dummyRC, dummyGISU,aConnectionGeometry);
+ }
+ else
+ {
+ aFirstSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+ }
if (aRC.IsNull() && !dummyRC.IsNull())
aRC = dummyRC;
}
else if (aFirstShapeL.Length() > 1) {
Handle(StepRepr_CompositeShapeAspect) aCSA;
- for (Standard_Integer shIt = 1; shIt <= aFirstShapeL.Length(); shIt++) {
- TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aFirstShapeL.Value(shIt));
- Handle(StepRepr_ShapeAspect) aSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+ for (Standard_Integer shIt = 1; shIt <= aFirstShapeL.Length(); shIt++)
+ {
+ const TDF_Label& aShLabel = aFirstShapeL.Value(shIt);
+ TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aShLabel);
+ Handle(TDataStd_UAttribute) aSupAttr;
+ Handle(StepRepr_ShapeAspect) aSA;
+ if (aShLabel.FindAttribute(XCAFDoc::SupplementalGeometryGUID(), aSupAttr))
+ {
+ aSA = WriteSupplementalGeometry(WS, aCGRepr, aShLabel, aShape, dummyRC, dummyGISU, aConnectionGeometry);
+ }
+ else
+ {
+ aSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+ }
if (aSA.IsNull())
continue;
if (aCSA.IsNull()) {
aFirstSA = aCSA;
}
if (aSecondShapeL.Length() == 1) {
- TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aSecondShapeL.Value(1));
- aSecondSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+ const TDF_Label& aShLabel = aSecondShapeL.Value(1);
+ TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aShLabel);
+ Handle(TDataStd_UAttribute) aSupAttr;
+ if (aShLabel.FindAttribute(XCAFDoc::SupplementalGeometryGUID(), aSupAttr))
+ {
+ aSecondSA = WriteSupplementalGeometry(WS, aCGRepr, aShLabel, aShape, dummyRC, dummyGISU, aConnectionGeometry);
+ }
+ else
+ {
+ aSecondSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+ }
if (aRC.IsNull() && !dummyRC.IsNull())
aRC = dummyRC;
}
else if (aSecondShapeL.Length() > 1) {
Handle(StepRepr_CompositeShapeAspect) aCSA;
for (Standard_Integer shIt = 1; shIt <= aSecondShapeL.Length(); shIt++) {
- TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aSecondShapeL.Value(shIt));
- Handle(StepRepr_ShapeAspect) aSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+ const TDF_Label& aShLabel = aSecondShapeL.Value(shIt);
+ TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aShLabel);
+ Handle(TDataStd_UAttribute) aSupAttr;
+ Handle(StepRepr_ShapeAspect) aSA;
+ if (aShLabel.FindAttribute(XCAFDoc::SupplementalGeometryGUID(), aSupAttr))
+ {
+ aSA = WriteSupplementalGeometry(WS, aCGRepr, aShLabel, aShape, dummyRC, dummyGISU, aConnectionGeometry);
+ }
+ else
+ {
+ aSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+ }
if (aCSA.IsNull() && !aSA.IsNull())
{
aCSA = new StepRepr_CompositeShapeAspect();
// Write dimensions
StepShape_DimensionalCharacteristic aDimension;
if (anObject->HasPoint() || anObject->HasPoint2())
- WriteDerivedGeometry(WS, anObject, aCGRepr, aFirstSA, aSecondSA, aConnectionPnts);
+ WriteDerivedGeometry(WS, anObject, aCGRepr, aFirstSA, aSecondSA, aConnectionGeometry);
XCAFDimTolObjects_DimensionType aDimType = anObject->GetType();
if (STEPCAFControl_GDTProperty::IsDimensionalLocation(aDimType)) {
// Dimensional_Location
anObject->GetPlane(), anObject->GetPointTextAttach(), aDimension.Value());
}
// Write Derived geometry
- if (aConnectionPnts.Length() > 0) {
- Handle(StepRepr_HArray1OfRepresentationItem) anItems = new StepRepr_HArray1OfRepresentationItem(1, aConnectionPnts.Length());
- for (Standard_Integer i = 0; i < aConnectionPnts.Length(); i++)
- anItems->SetValue(i + 1, aConnectionPnts(i));
+ if (aConnectionGeometry.Length() > 0) {
+ Handle(StepRepr_HArray1OfRepresentationItem) anItems = new StepRepr_HArray1OfRepresentationItem(1, aConnectionGeometry.Length());
+ for (Standard_Integer i = 0; i < aConnectionGeometry.Length(); i++)
+ anItems->SetValue(i + 1, aConnectionGeometry(i));
aCGRepr->Init(new TCollection_HAsciiString(), anItems, dummyRC);
aCGReprRel->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), dummyGISU->UsedRepresentation(), aCGRepr);
aModel->AddWithRefs(aCGReprRel);
return ID;
}
+//=======================================================================
+//function : SupplementalContainerGUID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc::SupplementalContainerGUID()
+{
+ static const Standard_GUID ID("da071945-9557-41b4-9e44-19e649f98b54");
+ return ID;
+}
+
+//=======================================================================
+//function : SupplementalRefGUID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc::SupplementalRefGUID()
+{
+ static const Standard_GUID ID("85a1b8d7-0936-4e8b-a953-a8bd7731411a");
+ return ID;
+}
+
+//=======================================================================
+//function : SupplementalGeometryGUID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc::SupplementalGeometryGUID()
+{
+ static const Standard_GUID ID("e17cce33-1aa2-4b7f-9060-6e469a7954a9");
+ return ID;
+}
//=======================================================================
//function : ExternRefGUID
//! Returns GUID for TreeNode representing assembly link
Standard_EXPORT static const Standard_GUID& ShapeRefGUID();
+
+ //! Returns GUID for TreeNode representing compound of supplemental geometry
+ Standard_EXPORT static const Standard_GUID& SupplementalContainerGUID();
+
+ //! Returns GUID for TreeNode representing reference for supplemental geometry
+ Standard_EXPORT static const Standard_GUID& SupplementalRefGUID();
+
+ //! Returns GUID for TreeNode representing supplemental geometry
+ Standard_EXPORT static const Standard_GUID& SupplementalGeometryGUID();
//! Return GUIDs for TreeNode representing specified types of colors
Standard_EXPORT static const Standard_GUID& ColorRefGUID (const XCAFDoc_ColorType type);