mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9bddb75927 | ||
|
82ec704d4e | ||
|
0d6efcedb2 |
@@ -182,8 +182,10 @@ Standard_Boolean XCAFDoc_Editor::Compact(const TDF_Label& theDoc,
|
|||||||
TDF_Label aChild = anIter.Value();
|
TDF_Label aChild = anIter.Value();
|
||||||
TDF_Label aPart;
|
TDF_Label aPart;
|
||||||
TopoDS_Shape aChildShape = aShapeTool->GetShape(aChild); // gets with own*ref location
|
TopoDS_Shape aChildShape = aShapeTool->GetShape(aChild); // gets with own*ref location
|
||||||
if (aShapeTool->GetReferredShape(aChild, aPart))
|
if (!aShapeTool->GetReferredShape(aChild, aPart))
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (aChildShape.ShapeType() == TopAbs_COMPOUND && aShapeTool->IsAssembly(aPart))
|
if (aChildShape.ShapeType() == TopAbs_COMPOUND && aShapeTool->IsAssembly(aPart))
|
||||||
{
|
{
|
||||||
// iterate next level if it needed
|
// iterate next level if it needed
|
||||||
@@ -231,8 +233,8 @@ Standard_Boolean XCAFDoc_Editor::Compact(const TDF_Label& theDoc,
|
|||||||
aPart.ForgetAllAttributes();
|
aPart.ForgetAllAttributes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
aShapeTool->SetShape(theAssemblyL, aCompound);
|
aShapeTool->SetShape(theAssemblyL, aCompound);
|
||||||
|
aShapeTool->UpdateAssemblies();
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,8 +410,8 @@ void XCAFDoc_Editor::CloneMetaData(const TDF_Label& theSrcLabel,
|
|||||||
}
|
}
|
||||||
const Standard_Boolean toCopyColor = theToCopyColor & XCAFDoc_DocumentTool::CheckColorTool(theSrcLabel);
|
const Standard_Boolean toCopyColor = theToCopyColor & XCAFDoc_DocumentTool::CheckColorTool(theSrcLabel);
|
||||||
const Standard_Boolean toCopyLayer = theToCopyLayer & XCAFDoc_DocumentTool::CheckLayerTool(theSrcLabel);
|
const Standard_Boolean toCopyLayer = theToCopyLayer & XCAFDoc_DocumentTool::CheckLayerTool(theSrcLabel);
|
||||||
const Standard_Boolean toCopyMaterial = theToCopyMaterial & XCAFDoc_DocumentTool::CheckLayerTool(theSrcLabel);
|
const Standard_Boolean toCopyMaterial = theToCopyMaterial & XCAFDoc_DocumentTool::CheckMaterialTool(theSrcLabel);
|
||||||
const Standard_Boolean toCopyVisMaterial = XCAFDoc_DocumentTool::CheckLayerTool(theSrcLabel);
|
const Standard_Boolean toCopyVisMaterial = XCAFDoc_DocumentTool::CheckVisMaterialTool(theSrcLabel);
|
||||||
// Colors
|
// Colors
|
||||||
if (toCopyColor)
|
if (toCopyColor)
|
||||||
{
|
{
|
||||||
|
@@ -33,33 +33,28 @@ public:
|
|||||||
|
|
||||||
DEFINE_STANDARD_ALLOC
|
DEFINE_STANDARD_ALLOC
|
||||||
|
|
||||||
//! Convert Shape (compound/compsolid/shell/wire) to assembly.
|
//! Converts shape (compound/compsolid/shell/wire) to assembly.
|
||||||
//! Only compounds expanded recursively
|
//! @param[in] theDoc input document
|
||||||
|
//! @param[in] theShape input shape label
|
||||||
|
//! @param[in] theRecursively recursively expand a compound subshape
|
||||||
|
//! @return True if shape successfully expanded
|
||||||
Standard_EXPORT static Standard_Boolean Expand(const TDF_Label& theDoc,
|
Standard_EXPORT static Standard_Boolean Expand(const TDF_Label& theDoc,
|
||||||
const TDF_Label& theShape,
|
const TDF_Label& theShape,
|
||||||
const Standard_Boolean theRecursively = Standard_True);
|
const Standard_Boolean theRecursively = Standard_True);
|
||||||
|
|
||||||
//! Convert all compounds in Doc to assembly
|
//! Converts all compounds shapes in the document to assembly
|
||||||
|
//! @param[in] theDoc input document
|
||||||
|
//! @param[in] theShape input shape label
|
||||||
|
//! @param[in] theRecursively recursively expand a compound subshape
|
||||||
|
//! @return True if shape successfully expanded
|
||||||
Standard_EXPORT static Standard_Boolean Expand(const TDF_Label& theDoc,
|
Standard_EXPORT static Standard_Boolean Expand(const TDF_Label& theDoc,
|
||||||
const Standard_Boolean theRecursively = Standard_True);
|
const Standard_Boolean theRecursively = Standard_True);
|
||||||
|
|
||||||
//! Extracts passed labels and put them as a component of theDstLabel
|
|
||||||
//! or creates new shape labels if theDstLabel is a main label of document
|
|
||||||
Standard_EXPORT static Standard_Boolean Extract(const TDF_LabelSequence& theSrcLabels,
|
|
||||||
const TDF_Label& theDstLabel,
|
|
||||||
const Standard_Boolean theIsNoVisMat = Standard_False);
|
|
||||||
|
|
||||||
//! Extracts passed label and put it as a component of theDstLabel
|
|
||||||
//! or creates new shape label if theDstLabel is a main label of document
|
|
||||||
Standard_EXPORT static Standard_Boolean Extract(const TDF_Label& theSrcLabel,
|
|
||||||
const TDF_Label& theDstLabel,
|
|
||||||
const Standard_Boolean theIsNoVisMat = Standard_False);
|
|
||||||
|
|
||||||
//! Replaces assembly's childs to referred parts with location, making simple compound.
|
//! Replaces assembly's childs to referred parts with location, making simple compound.
|
||||||
//! All parts without users are removed.
|
//! All parts without users are removed.
|
||||||
//! This action has an opposite effect to Expand() operation
|
//! This action has an opposite effect to Expand() operation
|
||||||
//! @param theDoc [in] input document
|
//! @param[in] theDoc input document
|
||||||
//! @param theAssemblyL [in] input assembly shape's label
|
//! @param[in] theAssemblyL input assembly shape's label
|
||||||
//! @return True if assembly label was successful compressed
|
//! @return True if assembly label was successful compressed
|
||||||
Standard_EXPORT static Standard_Boolean Compact(const TDF_Label& theDoc,
|
Standard_EXPORT static Standard_Boolean Compact(const TDF_Label& theDoc,
|
||||||
const TDF_Label& theAssemblyL);
|
const TDF_Label& theAssemblyL);
|
||||||
@@ -67,20 +62,49 @@ public:
|
|||||||
//! Converts all assembly shapes in the document to simple compounds.
|
//! Converts all assembly shapes in the document to simple compounds.
|
||||||
//! All parts without users are removed.
|
//! All parts without users are removed.
|
||||||
//! This action has an opposite effect to Expand() operation
|
//! This action has an opposite effect to Expand() operation
|
||||||
//! @param theDoc [in] input document
|
//! @param[in] theDoc input document
|
||||||
//! @return True if one or more assembly labels were successful compressed
|
//! @return True if one or more assembly labels were successful compressed
|
||||||
Standard_EXPORT static Standard_Boolean Compact(const TDF_Label& theDoc);
|
Standard_EXPORT static Standard_Boolean Compact(const TDF_Label& theDoc);
|
||||||
|
|
||||||
//! Copies shapes label with saving of shape structure (recursively)
|
//! Clones all labels to a new position, keeping the structure with all the attributes
|
||||||
//! theMap is a relating map of the original shapes label and labels created from them
|
//! @param[in] theSrcLabels original labels to copy from
|
||||||
|
//! @param[in] theDstLabel label to set result as a component of or a main document's label to simply set new shape
|
||||||
|
//! @param[in] theIsNoVisMat get a VisMaterial attributes as is or convert to color
|
||||||
|
//! @return True if shape successfully extracted
|
||||||
|
Standard_EXPORT static Standard_Boolean Extract(const TDF_LabelSequence& theSrcLabels,
|
||||||
|
const TDF_Label& theDstLabel,
|
||||||
|
const Standard_Boolean theIsNoVisMat = Standard_False);
|
||||||
|
|
||||||
|
//! Clones the label to a new position, keeping the structure with all the attributes
|
||||||
|
//! @param[in] theSrcLabel original label to copy from
|
||||||
|
//! @param[in] theDstLabel label to set result as a component of or a main document's label to simply set new shape
|
||||||
|
//! @param[in] theIsNoVisMat get a VisMaterial attributes as is or convert to color
|
||||||
|
//! @return True if shape successfully extracted
|
||||||
|
Standard_EXPORT static Standard_Boolean Extract(const TDF_Label& theSrcLabel,
|
||||||
|
const TDF_Label& theDstLabel,
|
||||||
|
const Standard_Boolean theIsNoVisMat = Standard_False);
|
||||||
|
|
||||||
|
//! Copies shapes label with keeping of shape structure (recursively)
|
||||||
|
//! @param[in] theSrcLabel original label to copy from
|
||||||
|
//! @param[in] theSrcShapeTool shape tool to get
|
||||||
|
//! @param[in] theDstShapeTool shape tool to set
|
||||||
|
//! @param[out] theMap relating map of the original shapes label and labels created from them
|
||||||
|
//! @return result shape label
|
||||||
Standard_EXPORT static TDF_Label CloneShapeLabel(const TDF_Label& theSrcLabel,
|
Standard_EXPORT static TDF_Label CloneShapeLabel(const TDF_Label& theSrcLabel,
|
||||||
const Handle(XCAFDoc_ShapeTool)& theSrcShapeTool,
|
const Handle(XCAFDoc_ShapeTool)& theSrcShapeTool,
|
||||||
const Handle(XCAFDoc_ShapeTool)& theDstShapeTool,
|
const Handle(XCAFDoc_ShapeTool)& theDstShapeTool,
|
||||||
TDF_LabelDataMap& theMap);
|
TDF_LabelDataMap& theMap);
|
||||||
|
|
||||||
//! Copies meta data conteins from the source label to the destination label
|
//! Copies metadata contains from the source label to the destination label.
|
||||||
//! theVisMatMap can be NULL, if theSrcLabel and theDstLabel located in the same document
|
|
||||||
//! Protected against creating a new label for non-existent tools
|
//! Protected against creating a new label for non-existent tools
|
||||||
|
//! @param[in] theSrcLabel original label to copy from
|
||||||
|
//! @param[in] theDstLabel destination shape label to set attributes
|
||||||
|
//! @param[in] theVisMatMap relating map of the original VisMaterial and created. Can be NULL for the same document
|
||||||
|
//! @param[in] theToCopyColor copying visible value and shape color (handled all color type)
|
||||||
|
//! @param[in] theToCopyLayer copying layer
|
||||||
|
//! @param[in] theToCopyMaterial copying material
|
||||||
|
//! @param[in] theToCopyVisMaterial copying visual material
|
||||||
|
//! @param[in] theToCopyAttributes copying of other node attributes, for example, a shape's property
|
||||||
Standard_EXPORT static void CloneMetaData(const TDF_Label& theSrcLabel,
|
Standard_EXPORT static void CloneMetaData(const TDF_Label& theSrcLabel,
|
||||||
const TDF_Label& theDstLabel,
|
const TDF_Label& theDstLabel,
|
||||||
NCollection_DataMap<Handle(XCAFDoc_VisMaterial), Handle(XCAFDoc_VisMaterial)>* theVisMatMap,
|
NCollection_DataMap<Handle(XCAFDoc_VisMaterial), Handle(XCAFDoc_VisMaterial)>* theVisMatMap,
|
||||||
|
@@ -703,61 +703,65 @@ static Standard_Integer Compact(Draw_Interpretor& di,
|
|||||||
{
|
{
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
di << "Use: " << argv[0] << " [-info] Doc [{shLabel1 shLabel2 ...}|{shape1 shape2 ...}]" << "\n";
|
di << "Syntax error: wrong number of arguments" << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Standard_Integer anArgcInd = 1;
|
|
||||||
Standard_Boolean toPrintInfo = Standard_False;
|
Standard_Boolean toPrintInfo = Standard_False;
|
||||||
if (argc > 2)
|
Handle(TDocStd_Document) aDoc;
|
||||||
|
Handle(XCAFDoc_ShapeTool) aShapeTool;
|
||||||
|
TDF_LabelSequence aShLabels;
|
||||||
|
for (Standard_Integer anInd = 1; anInd < argc; anInd++)
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aFirstArg(argv[anArgcInd]);
|
if (TCollection_AsciiString::IsSameString(argv[anInd], "-info", false))
|
||||||
aFirstArg.LowerCase();
|
|
||||||
if (aFirstArg.IsEqual("-info"))
|
|
||||||
{
|
{
|
||||||
toPrintInfo = Standard_True;
|
toPrintInfo = Standard_True;
|
||||||
anArgcInd++;
|
|
||||||
}
|
}
|
||||||
}
|
else if (aDoc.IsNull())
|
||||||
Handle(TDocStd_Document) aDoc;
|
{
|
||||||
DDocStd::GetDocument(argv[anArgcInd], aDoc);
|
DDocStd::GetDocument(argv[anInd], aDoc);
|
||||||
if (aDoc.IsNull())
|
if (aDoc.IsNull())
|
||||||
{
|
{
|
||||||
di << "Syntax error: " << argv[anArgcInd] << " is not a document" << "\n";
|
di << "Syntax error: " << argv[anInd] << " is not a document" << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (argc == 2)
|
aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TDF_Label aLabel;
|
||||||
|
TDF_Tool::Label(aDoc->GetData(), argv[anInd], aLabel);
|
||||||
|
if (aLabel.IsNull())
|
||||||
|
{
|
||||||
|
TopoDS_Shape aShape;
|
||||||
|
aShape = DBRep::Get(argv[anInd]);
|
||||||
|
aLabel = aShapeTool->FindShape(aShape);
|
||||||
|
}
|
||||||
|
if (!aLabel.IsNull())
|
||||||
|
{
|
||||||
|
aShLabels.Append(aLabel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
di << "Syntax error: " << argv[anInd] << " is not a shape" << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aShLabels.IsEmpty())
|
||||||
{
|
{
|
||||||
if (!XCAFDoc_Editor::Compact(aDoc->Main()) && toPrintInfo)
|
if (!XCAFDoc_Editor::Compact(aDoc->Main()) && toPrintInfo)
|
||||||
{
|
{
|
||||||
di << "The document does not contain any assembly shapes" << "\n";
|
di << "The document does not contain any assembly shapes" << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
for (TDF_LabelSequence::Iterator anIter(aShLabels); anIter.More(); anIter.Next())
|
||||||
{
|
|
||||||
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
|
|
||||||
for (; anArgcInd < argc; anArgcInd++)
|
|
||||||
{
|
|
||||||
TDF_Label aLabel;
|
|
||||||
TDF_Tool::Label(aDoc->GetData(), argv[anArgcInd], aLabel);
|
|
||||||
if (aLabel.IsNull())
|
|
||||||
{
|
|
||||||
TopoDS_Shape aShape;
|
|
||||||
aShape = DBRep::Get(argv[anArgcInd]);
|
|
||||||
aLabel = aShapeTool->FindShape(aShape);
|
|
||||||
}
|
|
||||||
if (!aLabel.IsNull())
|
|
||||||
{
|
{
|
||||||
|
const TDF_Label& aLabel = anIter.Value();
|
||||||
if (!XCAFDoc_Editor::Compact(aDoc->Main(), aLabel) && toPrintInfo)
|
if (!XCAFDoc_Editor::Compact(aDoc->Main(), aLabel) && toPrintInfo)
|
||||||
{
|
{
|
||||||
di << argv[anArgcInd] << " is not assembly" << "\n";
|
TCollection_AsciiString anEntry;
|
||||||
// continue iteration
|
TDF_Tool::Entry(aLabel, anEntry);
|
||||||
}
|
di << anEntry << " is not assembly" << "\n";
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
di << "Syntax error: " << argv[anArgcInd] << " is not a shape" << "\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user