Hide menu
Loading...
Searching...
No Matches
MTKConverter/main.cxx

Refer to the MTK Converter Example

MTKConverter_PartProcessor.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#ifndef _MTKConverter_PartProcessor_HeaderFile
#define _MTKConverter_PartProcessor_HeaderFile
#include <cadex/ModelData_Model.hxx>
#include <cadex/ModelData_Part.hxx>
#include <deque>
namespace cadex {
class ModelData_IndexedTriangleSet;
class ModelData_Shell;
class ModelData_Solid;
}
class MTKConverter_ProcessData
{
protected:
MTKConverter_ProcessData (const cadex::ModelData_Part& thePart) : myPart (thePart)
{}
public:
virtual ~MTKConverter_ProcessData() {}
};
class MTKConverter_PartProcessor : public cadex::ModelData_Model::VoidElementVisitor
{
public:
typedef std::shared_ptr<MTKConverter_ProcessData> DataType;
void operator() (const cadex::ModelData_Part& thePart) override;
virtual ~MTKConverter_PartProcessor() {}
std::deque<DataType> myData;
protected:
virtual void ProcessSolid (const cadex::ModelData_Part& thePart, const cadex::ModelData_Solid& theSolid) = 0;
virtual void ProcessShell (const cadex::ModelData_Part& thePart, const cadex::ModelData_Shell& theShell) = 0;
virtual void ProcessMesh (const cadex::ModelData_Part& thePart, const cadex::ModelData_IndexedTriangleSet& theMesh) = 0;
virtual void PostPartProcess (const cadex::ModelData_Part& thePart) = 0;
};
class MTKConverter_VoidPartProcessor : public MTKConverter_PartProcessor
{
protected:
void ProcessSolid (const cadex::ModelData_Part&, const cadex::ModelData_Solid&) override {}
void ProcessShell (const cadex::ModelData_Part&, const cadex::ModelData_Shell&) override {}
void ProcessMesh (const cadex::ModelData_Part&, const cadex::ModelData_IndexedTriangleSet&) override {}
void PostPartProcess (const cadex::ModelData_Part&) override {}
};
#endif
Defines a polygonal shape consisting of triangles.
Definition: ModelData_IndexedTriangleSet.hxx:35
Element visitor with empty implementation.
Definition: ModelData_Model.hxx:113
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
Defines a connected set of faces.
Definition: ModelData_Shell.hxx:31
Defines a topological solid.
Definition: ModelData_Solid.hxx:31
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22

MTKConverter_PartProcessor.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#include <cadex/ModelData_Body.hxx>
#include <cadex/ModelData_BodyList.hxx>
#include <cadex/ModelData_BRepRepresentation.hxx>
#include <cadex/ModelData_IndexedTriangleSet.hxx>
#include <cadex/ModelData_PolyRepresentation.hxx>
#include <cadex/ModelData_PolyShapeList.hxx>
#include <cadex/ModelData_Shell.hxx>
#include <cadex/ModelData_Solid.hxx>
#include <MTKConverter_PartProcessor.hxx>
using namespace cadex;
void MTKConverter_PartProcessor::operator() (const ModelData_Part& thePart)
{
if (auto aBRep = thePart.BRepRepresentation()) {
const auto& aBodyList = aBRep.Get();
for (size_t i = 0, n = aBodyList.Size(); i < n; ++i) {
const auto& aBody = aBodyList[i];
ModelData_Shape::Iterator aShapeIt (aBody);
while (aShapeIt.HasNext()) {
const auto& aShape = aShapeIt.Next();
if (aShape.Type() == ModelData_ST_Solid) {
ProcessSolid (thePart, ModelData_Solid::Cast (aShape));
} else if (aShape.Type() == ModelData_ST_Shell) {
ProcessShell (thePart, ModelData_Shell::Cast (aShape));
}
}
}
} else if (auto aPolyRep = thePart.PolyRepresentation (ModelData_RM_Poly)) {
const auto& aPolyList = aPolyRep.Get();
for (size_t i = 0; i < aPolyList.Size(); ++i) {
const auto& aPVS = aPolyList[i];
if (aPVS.IsOfType<ModelData_IndexedTriangleSet>()) {
ProcessMesh (thePart, static_cast<const ModelData_IndexedTriangleSet&> (aPVS));
}
}
}
PostPartProcess (thePart);
}
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
ModelData_PolyRepresentation PolyRepresentation(ModelData_RepresentationMask theRepresentationMask) const
Definition: ModelData_Part.cxx:371
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41

MTKConverter_WallThicknessProcessor.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#ifndef _MTKConverter_WallThicknessProcessor_HeaderFile
#define _MTKConverter_WallThicknessProcessor_HeaderFile
#include <cadex/ModelData_Point.hxx>
#include <cadex/WallThickness_Analyzer.hxx>
#include <MTKConverter_PartProcessor.hxx>
namespace cadex {
class WallThickness_Data;
}
typedef std::pair<cadex::ModelData_Point, cadex::ModelData_Point> PointPairType;
class MTKConverter_WallThicknessData : public MTKConverter_ProcessData
{
public:
MTKConverter_WallThicknessData (const cadex::ModelData_Part& thePart) : MTKConverter_ProcessData (thePart)
{}
bool myIsInit = false;
double myMinThickness = HUGE_VAL;
double myMaxThickness = -HUGE_VAL;
PointPairType myMinThicknessPoints;
PointPairType myMaxThicknessPoints;
};
class MTKConverter_WallThicknessProcessor : public MTKConverter_VoidPartProcessor
{
public:
MTKConverter_WallThicknessProcessor (size_t theResolution) : myResolution (theResolution)
{}
private:
void ProcessSolid (const cadex::ModelData_Part& thePart, const cadex::ModelData_Solid& theSolid) override;
void ProcessMesh (const cadex::ModelData_Part& thePart, const cadex::ModelData_IndexedTriangleSet& theMesh) override;
void UpdateProcessData (const cadex::WallThickness_Data& theData, const cadex::ModelData_Part& thePart);
size_t myResolution = 1000;
};
#endif
The wall thickness analyzing tool.
Definition: WallThickness_Analyzer.hxx:42
Contains information about minimum and maximum wall thicknesses.
Definition: WallThickness_Data.hxx:39

MTKConverter_WallThicknessProcessor.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#include <cadex/WallThickness_Data.hxx>
#include <MTKConverter_WallThicknessProcessor.hxx>
using namespace cadex;
void MTKConverter_WallThicknessProcessor::UpdateProcessData (const WallThickness_Data& theData, const ModelData_Part& thePart)
{
auto aWTData = std::make_shared<MTKConverter_WallThicknessData> (thePart);
myData.push_back (aWTData);
if (theData.IsEmpty()) {
return;
}
aWTData->myIsInit = true;
if (aWTData->myMinThickness > theData.MinThickness()) {
aWTData->myMinThickness = theData.MinThickness();
theData.PointsOfMinThickness (aWTData->myMinThicknessPoints.first, aWTData->myMinThicknessPoints.second);
}
if (aWTData->myMaxThickness < theData.MaxThickness()) {
aWTData->myMaxThickness = theData.MaxThickness();
theData.PointsOfMaxThickness (aWTData->myMaxThicknessPoints.first, aWTData->myMaxThicknessPoints.second);
}
}
void MTKConverter_WallThicknessProcessor::ProcessSolid (const ModelData_Part& thePart, const ModelData_Solid& theSolid)
{
auto aWTData = myAnalyzer.Perform (theSolid, myResolution);
UpdateProcessData (aWTData, thePart);
}
void MTKConverter_WallThicknessProcessor::ProcessMesh (const ModelData_Part& thePart,
{
auto aWTData = myAnalyzer.Perform (theMesh, myResolution);
UpdateProcessData (aWTData, thePart);
}
double MaxThickness() const
Returns the maximum wall thickness in mm.
Definition: WallThickness_Data.cxx:69
bool IsEmpty() const
Returns true if WallThickness_Data is empty.
Definition: WallThickness_Data.cxx:97
double MinThickness() const
Returns the minimum wall thickness in mm.
Definition: WallThickness_Data.cxx:63
void PointsOfMaxThickness(ModelData_Point &theFirstPoint, ModelData_Point &theSecondPoint) const
Returns points of maximum thickness.
Definition: WallThickness_Data.cxx:90
void PointsOfMinThickness(ModelData_Point &theFirstPoint, ModelData_Point &theSecondPoint) const
Returns points of minimum thickness.
Definition: WallThickness_Data.cxx:79

MTKConverter_MachiningProcessor.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#ifndef _MTKConverter_MachiningProcessor_HeaderFile
#define _MTKConverter_MachiningProcessor_HeaderFile
#include <cadex/Machining_OperationType.hxx>
#include <cadex/MTKBase_FeatureList.hxx>
#include <MTKConverter_PartProcessor.hxx>
namespace cadex {
class ModelData_Solid;
}
class MTKConverter_MachiningData : public MTKConverter_ProcessData
{
public:
MTKConverter_MachiningData (const cadex::ModelData_Part& thePart) : MTKConverter_ProcessData (thePart)
{}
};
class MTKConverter_MachiningProcessor : public MTKConverter_VoidPartProcessor
{
public:
MTKConverter_MachiningProcessor (cadex::Machining_OperationType theOperation) : myOperation (theOperation)
{}
protected:
void ProcessSolid (const cadex::ModelData_Part& thePart, const cadex::ModelData_Solid& theSolid) override;
};
#endif
Defines a list of features.
Definition: MTKBase_FeatureList.hxx:37
Machining_OperationType
Defines an operation type in machining.
Definition: Machining_OperationType.hxx:29

MTKConverter_MachiningProcessor.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#include <cadex/DFMMachining_Analyzer.hxx>
#include <cadex/DFMMachining_DeepPocketIssue.hxx>
#include <cadex/DFMMachining_DrillingAnalyzerParameters.hxx>
#include <cadex/DFMMachining_MillingAnalyzerParameters.hxx>
#include <cadex/DFMMachining_TurningAnalyzerParameters.hxx>
#include <cadex/Machining_Analyzer.hxx>
#include <cadex/Machining_Data.hxx>
#include <cadex/Machining_FeatureRecognizer.hxx>
#include <cadex/Machining_FeatureRecognizerParameters.hxx>
#include <cadex/ModelData_Solid.hxx>
#include <cadex/MTKBase_FeatureList.hxx>
#include <MTKConverter_MachiningProcessor.hxx>
using namespace cadex;
void MTKConverter_MachiningProcessor::ProcessSolid (const ModelData_Part& thePart, const ModelData_Solid& theSolid)
{
auto aMachiningData = std::make_shared<MTKConverter_MachiningData> (thePart);
myData.push_back (aMachiningData);
aMachiningData->myOperation = myOperation;
Machining_FeatureRecognizer aFeatureRecognizer;
aFeatureRecognizer.Parameters().SetOperation (myOperation);
Machining_Analyzer anAnalyzer;
anAnalyzer.AddTool (aFeatureRecognizer);
auto aData = anAnalyzer.Perform (theSolid);
if (aData.IsEmpty()) {
return;
}
//features
aMachiningData->myFeatureList = aData.FeatureList();
//issues
DFMMachining_Analyzer aDrillingAnalyzer (aDrillingParameters);
aMachiningData->myIssueList = aDrillingAnalyzer.Perform (theSolid, aData);
DFMMachining_Analyzer aMillingAnalyzer (aMillingParameters);
MTKBase_FeatureList aMillingIssueList = aMillingAnalyzer.Perform (theSolid, aData);
for (size_t i = 0; i < aMillingIssueList.Size(); ++i) {
const auto& anIssue = aMillingIssueList[i];
if (myOperation == Machining_OT_LatheMilling
&& !anIssue.IsOfType<DFMMachining_DeepPocketIssue>()) {
continue;
}
aMachiningData->myIssueList.Append (anIssue);
}
if (myOperation == Machining_OT_LatheMilling) {
DFMMachining_Analyzer aTurningAnalyzer (aTurninigParameters);
MTKBase_FeatureList aTurningIssueList = aTurningAnalyzer.Perform (theSolid, aData);
for (size_t i = 0; i < aTurningIssueList.Size(); ++i) {
const auto& anIssue = aTurningIssueList[i];
aMachiningData->myIssueList.Append (anIssue);
}
}
}
Provides an interface to run DFM Machining analysis.
Definition: DFMMachining_Analyzer.hxx:43
MTKBase_FeatureList Perform(const ModelData_Solid &theSolid, const cadex::Base_ProgressStatus &theProgressStatus=cadex::Base_ProgressStatus())
Runs analyzing process.
Definition: DFMMachining_Analyzer.cxx:112
Describes deep pocket issue found during cnc machining milling design analysis.
Definition: DFMMachining_DeepPocketIssue.hxx:33
Defines parameters used in cnc machining drilling design analysis.
Definition: DFMMachining_DrillingAnalyzerParameters.hxx:33
Defines parameters used in cnc machining milling design analysis.
Definition: DFMMachining_MillingAnalyzerParameters.hxx:35
Defines parameters used in cnc machining turning design analysis.
Definition: DFMMachining_TurningAnalyzerParameters.hxx:35
size_t Size() const
Returns the number of elements in the list.
Definition: MTKBase_FeatureList.cxx:87
void Append(const MTKBase_Feature &theFeature)
Adds a feature to the list.
Definition: MTKBase_FeatureList.cxx:55
Provides an interface to run several analyzer tools for different types of machining processing.
Definition: Machining_Analyzer.hxx:42
Machining_Data Perform(const ModelData_Solid &theSolid, const cadex::Base_ProgressStatus &theProgressStatus=cadex::Base_ProgressStatus())
Runs the analyzing process.
Definition: Machining_Analyzer.cxx:79
void AddTool(const Machining_AnalyzerTool &theTool)
Adds additional tool to run during analyzing process.
Definition: Machining_Analyzer.cxx:99
const MTKBase_FeatureList & FeatureList() const
Definition: Machining_Data.cxx:49
Provides an interface to recognizing machining features tool.
Definition: Machining_FeatureRecognizer.hxx:43
const Machining_FeatureRecognizerParameters & Parameters() const
Returns parameters.
Definition: Machining_FeatureRecognizer.cxx:287
void SetOperation(Machining_OperationType theOperation)
Definition: Machining_FeatureRecognizerParameters.cxx:205

MTKConverter_SheetMetalProcessor.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#ifndef _MTKConverter_SheetMetalProcessor_HeaderFile
#define _MTKConverter_SheetMetalProcessor_HeaderFile
#include <cadex/ModelData_BRepRepresentation.hxx>
#include <cadex/ModelData_Shell.hxx>
#include <cadex/MTKBase_FeatureList.hxx>
#include <cadex/SheetMetal_Analyzer.hxx>
#include <cadex/SheetMetal_Data.hxx>
#include <cadex/SheetMetal_FlatPattern.hxx>
#include <MTKConverter_PartProcessor.hxx>
class MTKConverter_UnfoldedPartData
{
public:
MTKConverter_UnfoldedPartData()
{}
bool IsInit() const { return !!myFlatPattern; }
};
class MTKConverter_SheetMetalData : public MTKConverter_ProcessData
{
public:
MTKConverter_SheetMetalData (const cadex::ModelData_Part& thePart);
bool myIsSheetMetalPart = true;
MTKConverter_UnfoldedPartData myUnfoldedPartData;
};
class MTKConverter_SheetMetalProcessor : public MTKConverter_VoidPartProcessor
{
public:
MTKConverter_SheetMetalProcessor (cadex::ModelData_Model& theUnfoldedModel);
protected:
void ProcessSolid (const cadex::ModelData_Part& thePart, const cadex::ModelData_Solid& theSolid) override;
void ProcessShell (const cadex::ModelData_Part& thePart, const cadex::ModelData_Shell& theShell) override;
void PostPartProcess (const cadex::ModelData_Part& thePart) override;
void UpdateProcessData (const cadex::SheetMetal_Data& theData, const cadex::ModelData_Part& thePart);
cadex::ModelData_Model& myUnfoldedModel;
cadex::ModelData_BRepRepresentation myCurrentUnfoldedBRep;
};
#endif
Defines precise Boundary Representation of part.
Definition: ModelData_BRepRepresentation.hxx:39
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
Provides an interface to run several analyzer tools.
Definition: SheetMetal_Analyzer.hxx:43
Contains specific information for sheet metal tools.
Definition: SheetMetal_Data.hxx:40
Describes a flat pattern for sheet metal models.
Definition: SheetMetal_FlatPattern.hxx:38

MTKConverter_SheetMetalProcessor.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#include <cadex/Base_Uuid.hxx>
#include <cadex/DFMSheetMetal_Analyzer.hxx>
#include <cadex/DFMSheetMetal_FlatPatternInterferenceIssue.hxx>
#include <cadex/DFMSheetMetal_NonStandardSheetSizeIssue.hxx>
#include <cadex/DFMSheetMetal_NonStandardSheetThicknessIssue.hxx>
#include <cadex/ModelAlgo_BoundingBox.hxx>
#include <cadex/ModelAlgo_BRepMesher.hxx>
#include <cadex/ModelAlgo_ValidationProperty.hxx>
#include <cadex/ModelAlgo_ValidationPropertyData.hxx>
#include <cadex/ModelData_Box.hxx>
#include <cadex/ModelData_Shell.hxx>
#include <cadex/ModelData_Solid.hxx>
#include <cadex/ModelData_Transformation.hxx>
#include <cadex/SheetMetal_Analyzer.hxx>
#include <cadex/SheetMetal_Data.hxx>
#include <cadex/SheetMetal_FeatureRecognizer.hxx>
#include <cadex/SheetMetal_FlatPattern.hxx>
#include <cadex/SheetMetal_Unfolder.hxx>
#include <MTKConverter_SheetMetalProcessor.hxx>
#include <vector>
using namespace cadex;
MTKConverter_SheetMetalData::MTKConverter_SheetMetalData (const cadex::ModelData_Part& thePart) :
MTKConverter_ProcessData (thePart)
{}
namespace {
double CalculateInitialThicknessValue (const ModelData_Shape& theShape)
{
double aVolume = ModelAlgo_ValidationProperty::ComputeVolume (theShape);
double aSurfaceArea = ModelAlgo_ValidationProperty::ComputeSurfaceArea (theShape);
double aThickness = aVolume / (aSurfaceArea / 2.);
return aThickness;
}
}
MTKConverter_SheetMetalProcessor::MTKConverter_SheetMetalProcessor (cadex::ModelData_Model& theUnfoldedModel) :
myUnfoldedModel (theUnfoldedModel)
{
myAnalyzer.AddTool (SheetMetal_FeatureRecognizer());
myAnalyzer.AddTool (SheetMetal_Unfolder());
}
void MTKConverter_SheetMetalProcessor::ProcessSolid (
const cadex::ModelData_Part& thePart, const cadex::ModelData_Solid& theSolid)
{
auto anSMData = myAnalyzer.Perform (theSolid, CalculateInitialThicknessValue (theSolid));
UpdateProcessData (anSMData, thePart);
}
void MTKConverter_SheetMetalProcessor::ProcessShell (
const cadex::ModelData_Part& thePart, const cadex::ModelData_Shell& theShell)
{
auto anSMData = myAnalyzer.Perform (theShell);
UpdateProcessData (anSMData, thePart);
}
void MTKConverter_SheetMetalProcessor::PostPartProcess (const ModelData_Part& thePart)
{
if (!myCurrentUnfoldedBRep) {
return;
}
ModelData_Part anUnfoldedPart (thePart.Name());
anUnfoldedPart.SetUuid (thePart.Uuid());
anUnfoldedPart.AddRepresentation (myCurrentUnfoldedBRep);
aMesher.Compute (anUnfoldedPart);
myUnfoldedModel.AddRoot (anUnfoldedPart);
myCurrentUnfoldedBRep = ModelData_BRepRepresentation();
}
void MTKConverter_SheetMetalProcessor::UpdateProcessData (
const cadex::SheetMetal_Data& theData, const cadex::ModelData_Part& thePart)
{
auto anSMData = std::make_shared<MTKConverter_SheetMetalData> (thePart);
myData.push_back (anSMData);
if (theData.IsEmpty()) {
anSMData->myIsSheetMetalPart = false;
return;
}
anSMData->myFeatureList = theData.FeatureList();
const auto& aFlatPattern = theData.FlatPattern();
const auto& anUnfoldedShell = aFlatPattern ? aFlatPattern.UnfoldedShell() : ModelData_Shell();
auto& anUnfoldedData = anSMData->myUnfoldedPartData;
if (anUnfoldedShell) {
myCurrentUnfoldedBRep.Add (anUnfoldedShell);
anUnfoldedData.myBRep = myCurrentUnfoldedBRep;
anUnfoldedData.myFlatPattern = aFlatPattern;
}
DFMSheetMetal_Analyzer aDFMAnalyzer;
auto anIssueList = aDFMAnalyzer.Perform (theData);
for (size_t i = 0; i < anIssueList.Size(); ++i) {
const auto& anIssue = anIssueList[i];
if (anUnfoldedData.IsInit()
anUnfoldedData.myIssueList.Append (anIssue);
} else {
anSMData->myIssueList.Append (anIssue);
}
}
}
Provides an interface to run DFM Sheet Metal analysis.
Definition: DFMSheetMetal_Analyzer.hxx:45
MTKBase_FeatureList Perform(const ModelData_Solid &theSolid, double theThickness, const cadex::Base_ProgressStatus &theProgressStatus=cadex::Base_ProgressStatus())
Definition: DFMSheetMetal_Analyzer.cxx:1565
Describes interference issue for flat pattern found during sheet metal design analysis.
Definition: DFMSheetMetal_FlatPatternInterferenceIssue.hxx:33
Describes non standard sheet size issue found during sheet metal design analysis.
Definition: DFMSheetMetal_NonStandardSheetSizeIssue.hxx:33
Describes non standard sheet thickness issue found during sheet metal design analysis.
Definition: DFMSheetMetal_NonStandardSheetThicknessIssue.hxx:31
Computes a polygonal representation from a B-Rep one.
Definition: ModelAlgo_BRepMesher.hxx:48
void Compute(const ModelData_Model &theModel, bool theEnforceAddition=false) const
Computes polygonal representations for all parts in the model.
Definition: ModelAlgo_BRepMesher.cxx:478
Base_Uuid Uuid() const
Definition: ModelData_BaseObject.cxx:240
Base_UTF16String Name() const
Definition: ModelData_BaseObject.cxx:218
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37
bool IsEmpty() const
Returns true if the data is empty.
Definition: SheetMetal_Data.cxx:104
const SheetMetal_FlatPattern & FlatPattern() const
Definition: SheetMetal_Data.cxx:98
const MTKBase_FeatureList & FeatureList() const
Definition: SheetMetal_Data.cxx:89
Provides an interface to recognizing sheet metal features tool. Is used for recognition of features s...
Definition: SheetMetal_FeatureRecognizer.hxx:38
ModelData_Shell UnfoldedShell() const
Returns the unfolded shell for flat pattern.
Definition: SheetMetal_FlatPattern.cxx:115
Is used to unfold sheet metal models.
Definition: SheetMetal_Unfolder.hxx:39

MTKConverter_Report.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#ifndef _MTKConverter_Report_HeaderFile
#define _MTKConverter_Report_HeaderFile
#include <cadex/Base_UTF16String.hxx>
#include <deque>
#include <memory>
class MTKConverter_ProcessData;
class MTKConverter_Report
{
public:
typedef std::shared_ptr<MTKConverter_ProcessData> DataType;
void AddData (const DataType& theData) { myData.push_back (theData); }
bool WriteToJSON (const cadex::Base_UTF16String& thePath) const;
private:
std::deque<DataType> myData;
};
#endif
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34

MTKConverter_Report.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <cadex/Base_Uuid.hxx>
#include <cadex/DFMMachining_DeepBoredHoleIssue.hxx>
#include <cadex/DFMMachining_DeepHoleIssue.hxx>
#include <cadex/DFMMachining_DeepPocketIssue.hxx>
#include <cadex/DFMMachining_FlatBottomHoleIssue.hxx>
#include <cadex/DFMMachining_HighBossIssue.hxx>
#include <cadex/DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue.hxx>
#include <cadex/DFMMachining_IntersectingCavityHoleIssue.hxx>
#include <cadex/DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue.hxx>
#include <cadex/DFMMachining_LargeMilledPartIssue.hxx>
#include <cadex/DFMMachining_LargeTurnedPartIssue.hxx>
#include <cadex/DFMMachining_LongSlenderTurnedPartIssue.hxx>
#include <cadex/DFMMachining_MilledPartExternalEdgeFilletIssue.hxx>
#include <cadex/DFMMachining_MilledPartSize.hxx>
#include <cadex/DFMMachining_NonPerpendicularHoleIssue.hxx>
#include <cadex/DFMMachining_NonPerpendicularMilledPartShapeIssue.hxx>
#include <cadex/DFMMachining_NonStandardDiameterHoleIssue.hxx>
#include <cadex/DFMMachining_NonStandardDrillPointAngleBlindHoleIssue.hxx>
#include <cadex/DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue.hxx>
#include <cadex/DFMMachining_NonSymmetricalAxialSlotIssue.hxx>
#include <cadex/DFMMachining_PartialHoleIssue.hxx>
#include <cadex/DFMMachining_SmallDepthBlindBoredHoleReliefIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDepthLouverIssue.hxx>
#include <cadex/DFMMachining_SmallDiameterHoleIssue.hxx>
#include <cadex/DFMMachining_SmallRadiusMilledPartInternalCornerIssue.hxx>
#include <cadex/DFMMachining_SmallRadiusTurnedPartInternalCornerIssue.hxx>
#include <cadex/DFMMachining_SquareEndKeywayIssue.hxx>
#include <cadex/DFMMachining_TurnedPartSize.hxx>
#include <cadex/DFMMachining_LargeDifferenceRegionsSizeInPocketIssue.hxx>
#include <cadex/DFMMachining_NarrowRegionInPocketIssue.hxx>
#include <cadex/DFMSheetMetal_FlatPatternInterferenceIssue.hxx>
#include <cadex/DFMSheetMetal_InconsistentRadiusBendIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularDepthExtrudedHoleIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularRadiusOpenHemBendIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularSizeBendReliefIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularSizeNotchIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularSizeTabIssue.hxx>
#include <cadex/DFMSheetMetal_LargeDepthBeadIssue.hxx>
#include <cadex/DFMSheetMetal_NonStandardSheetSizeIssue.hxx>
#include <cadex/DFMSheetMetal_NonStandardSheetThicknessIssue.hxx>
#include <cadex/DFMSheetMetal_SheetSize.hxx>
#include <cadex/DFMSheetMetal_SmallDiameterHoleIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHolesIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenNotchesIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenTabsIssue.hxx>
#include <cadex/DFMSheetMetal_SmallLengthFlangeIssue.hxx>
#include <cadex/DFMSheetMetal_SmallLengthHemBendFlangeIssue.hxx>
#include <cadex/DFMSheetMetal_SmallRadiusBendIssue.hxx>
#include <cadex/MTKBase_Boss.hxx>
#include <cadex/Machining_Face.hxx>
#include <cadex/Machining_Hole.hxx>
#include <cadex/Machining_Countersink.hxx>
#include <cadex/Machining_Pocket.hxx>
#include <cadex/Machining_TurningFace.hxx>
#include <cadex/ModelData_Axis1Placement.hxx>
#include <cadex/ModelData_Axis3Placement.hxx>
#include <cadex/ModelData_Body.hxx>
#include <cadex/ModelData_BodyList.hxx>
#include <cadex/ModelData_BRepRepresentation.hxx>
#include <cadex/ModelData_Direction.hxx>
#include <cadex/ModelData_Edge.hxx>
#include <cadex/ModelData_Face.hxx>
#include <cadex/ModelData_Part.hxx>
#include <cadex/ModelData_PolyRepresentation.hxx>
#include <cadex/ModelData_Shape.hxx>
#include <cadex/ModelData_Shell.hxx>
#include <cadex/SheetMetal_Bead.hxx>
#include <cadex/SheetMetal_Bend.hxx>
#include <cadex/SheetMetal_BendRelief.hxx>
#include <cadex/SheetMetal_Bridge.hxx>
#include <cadex/SheetMetal_ComplexHole.hxx>
#include <cadex/SheetMetal_CompoundBend.hxx>
#include <cadex/SheetMetal_CurvedBend.hxx>
#include <cadex/SheetMetal_Cutout.hxx>
#include <cadex/SheetMetal_HemBend.hxx>
#include <cadex/SheetMetal_HemBendType.hxx>
#include <cadex/SheetMetal_Hole.hxx>
#include <cadex/SheetMetal_Louver.hxx>
#include <cadex/SheetMetal_StraightNotch.hxx>
#include <cadex/SheetMetal_Tab.hxx>
#include <cadex/SheetMetal_VNotch.hxx>
#include <cadex/MTKBase_FeatureComparator.hxx>
#include <MTKConverter_Report.hxx>
#include <MTKConverter_MachiningProcessor.hxx>
#include <MTKConverter_SheetMetalProcessor.hxx>
#include <MTKConverter_WallThicknessProcessor.hxx>
#include <array>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <map>
#include <sstream>
#include <vector>
using namespace cadex;
namespace {
typedef std::pair<double, double> PairType;
typedef std::array<double, 3> ArrayType;
inline std::ostream& operator<< (std::ostream& theStream, const PairType& thePair)
{
return theStream << thePair.first << " x " << thePair.second;
}
inline std::ostream& operator<< (std::ostream& theStream, const ModelData_Direction& theDir)
{
return theStream << "(" << theDir.X() << ", " << theDir.Y() << ", " << theDir.Z() << ")";
}
inline std::ostream& operator<< (std::ostream& theStream, const ModelData_Point& thePoint)
{
return theStream << "(" << thePoint.X() << ", " << thePoint.Y() << ", " << thePoint.Z() << ")";
}
inline std::ostream& operator<< (std::ostream& theStream, const ArrayType& theArray)
{
return theStream << theArray[0] << " x " << theArray[1] << " x " << theArray[2];
}
class JSONWriter
{
public:
JSONWriter (std::ostream& theStream, int theStartNestingLevel = 0) : myStream (theStream),
myNestingLevel (theStartNestingLevel),
myPrevNestingLevel (theStartNestingLevel - 1)
{}
void OpenSection()
{
DoOpenSection (nullptr, '{');
}
void OpenSection (const char* theName)
{
DoOpenSection (theName, '{');
}
void OpenArraySection (const char* theName)
{
DoOpenSection (theName, '[');
}
void CloseSection()
{
DoCloseSection ('}');
}
void CloseArraySection()
{
DoCloseSection (']');
}
template<typename T>
void WriteData (const char* theParamName, const T& theValue)
{
Stream() << "\"" << theParamName << "\": \"" << theValue << "\"";
}
void WriteRawData (const std::string& theRawData)
{
PrepareStream();
myStream << theRawData;
}
void WriteEmptyArray (const char* theParamName)
{
Stream() << "\"" << theParamName << "\": []";
}
int NestingLevel() const { return myNestingLevel; }
private:
void DoOpenSection (const char* theName, char theOpenBracketSymbol)
{
auto& aStream = Stream();
if (theName) {
aStream << "\"" << theName << "\": ";
}
aStream << theOpenBracketSymbol;
++myNestingLevel;
}
void DoCloseSection (char theCloseBracketSymbol)
{
--myNestingLevel;
Stream() << theCloseBracketSymbol;
}
void PrepareStream()
{
if (myNestingLevel == myPrevNestingLevel) {
myStream << ",";
}
myPrevNestingLevel = myNestingLevel;
if (myIsInit) {
myStream << std::endl;
}
myIsInit = true;
}
std::ostream& Stream()
{
PrepareStream();
for (int i = 0; i < myNestingLevel; ++i) {
myStream << " ";
}
return myStream;
}
std::ostream& myStream;
bool myIsInit = false;
int myNestingLevel;
int myPrevNestingLevel;
};
typedef std::vector<int> ShapeIDVectorType;
typedef std::vector<ShapeIDVectorType> ShapeIDVectorVectorType;
typedef std::shared_ptr<MTKConverter_ProcessData> DataType;
typedef std::map<MTKBase_Feature,
std::pair<size_t, ShapeIDVectorVectorType>,
MTKBase_FeatureComparator> FeatureMapType;
typedef std::vector<FeatureMapType::value_type> TypedFeatureVecType;
template <typename T>
void WriteParameter (JSONWriter& theWriter, const char* theParamName, const char* theParamUnits, const T& theParamValue)
{
theWriter.OpenSection();
theWriter.WriteData ("name", theParamName);
theWriter.WriteData ("units", theParamUnits);
theWriter.WriteData ("value", theParamValue);
theWriter.CloseSection();
}
void WriteShapeIDs (JSONWriter& theWriter, const ShapeIDVectorVectorType& theVector)
{
if (theVector.empty()) {
return;
}
theWriter.WriteData ("featureCount", theVector.size());
theWriter.OpenArraySection ("features");
for (const auto& aShapeIDVector : theVector) {
theWriter.OpenSection();
theWriter.WriteData ("shapeIDCount", aShapeIDVector.size());
if (aShapeIDVector.empty()) {
theWriter.WriteEmptyArray ("shapeIDs");
} else {
theWriter.OpenArraySection ("shapeIDs");
for (auto aShapeID : aShapeIDVector) {
theWriter.OpenSection();
theWriter.WriteData ("id", aShapeID);
theWriter.CloseSection();
}
theWriter.CloseArraySection();
}
theWriter.CloseSection();
}
theWriter.CloseArraySection();
}
template <typename F>
std::string DoWriteFeatureDataToString (const F& theFunc,
int theParamCount,
const ShapeIDVectorVectorType& theVector)
{
std::stringstream aStream;
aStream << std::fixed << std::setprecision (2);
JSONWriter aWriter (aStream, 7);
aWriter.OpenSection();
aWriter.WriteData ("parametersCount", theParamCount);
aWriter.OpenArraySection ("parameters");
theFunc (aWriter);
aWriter.CloseArraySection();
WriteShapeIDs (aWriter, theVector);
aWriter.CloseSection();
return aStream.str();
}
std::string WriteFeatureDataToString (const ShapeIDVectorVectorType& theVector)
{
std::stringstream aStream;
JSONWriter aWriter (aStream, 6);
WriteShapeIDs (aWriter, theVector);
return aStream.str();
}
template <typename T>
std::string WriteFeatureDataToString (const char* theParamName,
const char* theParamUnits,
const T& theParamValue,
const ShapeIDVectorVectorType& theVector)
{
auto WriteParams = [&] (JSONWriter& theWriter) {
WriteParameter (theWriter, theParamName, theParamUnits, theParamValue);
};
return DoWriteFeatureDataToString (WriteParams, 1, theVector);
}
template <typename T1, typename T2>
std::string WriteFeatureDataToString (const char* theParamName1,
const char* theParamUnits1,
const T1& theParamValue1,
const char* theParamName2,
const char* theParamUnits2,
const T2& theParamValue2,
const ShapeIDVectorVectorType& theVector)
{
auto WriteParams = [&] (JSONWriter& theWriter) {
WriteParameter (theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter (theWriter, theParamName2, theParamUnits2, theParamValue2);
};
return DoWriteFeatureDataToString (WriteParams, 2, theVector);
}
template <typename T1, typename T2, typename T3>
std::string WriteFeatureDataToString (const char* theParamName1,
const char* theParamUnits1,
const T1& theParamValue1,
const char* theParamName2,
const char* theParamUnits2,
const T2& theParamValue2,
const char* theParamName3,
const char* theParamUnits3,
const T3& theParamValue3,
const ShapeIDVectorVectorType& theVector)
{
auto WriteParams = [&] (JSONWriter& theWriter) {
WriteParameter (theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter (theWriter, theParamName2, theParamUnits2, theParamValue2);
WriteParameter (theWriter, theParamName3, theParamUnits3, theParamValue3);
};
return DoWriteFeatureDataToString (WriteParams, 3, theVector);
}
template <typename T1, typename T2, typename T3, typename T4>
std::string WriteFeatureDataToString (const char* theParamName1,
const char* theParamUnits1,
const T1& theParamValue1,
const char* theParamName2,
const char* theParamUnits2,
const T2& theParamValue2,
const char* theParamName3,
const char* theParamUnits3,
const T3& theParamValue3,
const char* theParamName4,
const char* theParamUnits4,
const T4& theParamValue4,
const ShapeIDVectorVectorType& theVector)
{
auto WriteParams = [&] (JSONWriter& theWriter) {
WriteParameter (theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter (theWriter, theParamName2, theParamUnits2, theParamValue2);
WriteParameter (theWriter, theParamName3, theParamUnits3, theParamValue3);
WriteParameter (theWriter, theParamName4, theParamUnits4, theParamValue4);
};
return DoWriteFeatureDataToString (WriteParams, 4, theVector);
}
class FeatureGroupManager
{
public:
void AddGroupData (const char* theGroupName,
const char* theGroupColor,
const std::string& theFeatureData,
size_t theFeatureNb)
{
//find or create
auto aRes = std::find_if (myGroups.begin(), myGroups.end(),
[&] (const FeatureGroup& theGroup) { return theGroup.myName == theGroupName; });
if (aRes == myGroups.end()) {
aRes = myGroups.insert (aRes, FeatureGroup (theGroupName, theGroupColor));
}
//update
auto& aGroup = *aRes;
aGroup.myFeatureData.push_back (theFeatureData);
aGroup.myFeatureCount += theFeatureNb;
}
size_t TotalFeatureCount() const
{
size_t aTotalFeatureCount = 0;
for (const auto& aGroup : myGroups) {
aTotalFeatureCount += aGroup.myFeatureCount;
}
return aTotalFeatureCount;
}
void Write (JSONWriter& theWriter) const
{
for (const auto& aGroup : myGroups) {
theWriter.OpenSection();
theWriter.WriteData ("name", aGroup.myName);
theWriter.WriteData ("color", aGroup.myColor);
theWriter.WriteData ("totalGroupFeatureCount", aGroup.myFeatureCount);
const auto& aFeatureData = aGroup.myFeatureData;
if (!aFeatureData.empty()) {
bool aHasParams = aFeatureData.front().find ("parameters") != std::string::npos;
if (aHasParams) {
theWriter.WriteData ("subGroupCount", aFeatureData.size());
theWriter.OpenArraySection ("subGroups");
for (const auto& j : aFeatureData) {
theWriter.WriteRawData (j);
}
theWriter.CloseArraySection();
} else {
for (const auto& j : aFeatureData) {
theWriter.WriteRawData (j);
}
}
}
theWriter.CloseSection();
}
}
private:
class FeatureGroup
{
public:
FeatureGroup (const char* theName, const char* theColor) : myName (theName), myColor (theColor)
{}
std::string myName;
std::string myColor;
std::vector<std::string> myFeatureData;
size_t myFeatureCount = 0;
};
std::vector<FeatureGroup> myGroups;
};
const char* MachiningFaceTypeToString (Machining_FaceType theType)
{
switch (theType) {
case Machining_FT_FlatFaceMilled: return "Flat Face Milled Face(s)";
case Machining_FT_FlatSideMilled: return "Flat Side Milled Face(s)";
case Machining_FT_CurvedMilled: return "Curved Milled Face(s)";
case Machining_FT_CircularMilled: return "Circular Milled Face(s)";
case Machining_FT_Deburr: return "Deburr Face(s)";
case Machining_FT_ConvexProfileEdgeMilling: return "Convex Profile Edge Milling Face(s)";
case Machining_FT_ConcaveFilletEdgeMilling: return "Concave Fillet Edge Milling Face(s)";
case Machining_FT_FlatMilled: return "Flat Milled Face(s)";
case Machining_FT_TurnDiameter: return "Turn Diameter Face(s)";
case Machining_FT_TurnForm: return "Turn Form Face(s)";
case Machining_FT_TurnFace: return "Turn Face Face(s)";
case Machining_FT_Bore: return "Bore Face(s)";
default:
break;
}
return "Face(s)";
}
const char* MachiningFaceColor (Machining_FaceType theType)
{
switch (theType) {
case Machining_FT_FlatFaceMilled: return "(115, 251, 253)";
case Machining_FT_FlatSideMilled: return "(0, 35, 245)";
case Machining_FT_CurvedMilled: return "(22, 65, 124)";
case Machining_FT_CircularMilled: return "(255, 254, 145)";
case Machining_FT_Deburr: return "(0, 0, 0)";
case Machining_FT_ConvexProfileEdgeMilling: return "(240, 155, 89)";
case Machining_FT_ConcaveFilletEdgeMilling: return "(129, 127, 38)";
case Machining_FT_FlatMilled: return "(115, 43, 245)";
case Machining_FT_TurnDiameter: return "(88, 19, 94)";
case Machining_FT_TurnForm: return "(161, 251, 142)";
case Machining_FT_TurnFace: return "(239, 136, 190)";
case Machining_FT_Bore: return "(127, 130, 187)";
default:
break;
}
return "(0, 0, 0)";
}
const char* MachiningHoleTypeToString (Machining_HoleType theType)
{
switch (theType) {
case Machining_HT_Through: return "Through Hole(s)";
case Machining_HT_FlatBottom: return "Flat Bottom Hole(s)";
case Machining_HT_Blind: return "Blind Hole(s)";
case Machining_HT_Partial: return "Partial Hole(s)";
default:
break;
}
return "Hole(s)";
}
const char* MachiningHoleColor (Machining_HoleType theType)
{
switch (theType) {
case Machining_HT_Through: return "(240, 135, 132)";
case Machining_HT_FlatBottom: return "(235, 51, 36)";
case Machining_HT_Blind: return "(142, 64, 58)";
case Machining_HT_Partial: return "(58, 6, 3)";
default:
break;
}
return "(0, 0, 0)";
}
const char* HemTypeToString (SheetMetal_HemBendType theType)
{
switch (theType) {
case SheetMetal_HBT_Flattened: return "Flattened Hem Bend(s)";
case SheetMetal_HBT_Open: return "Open Hem Bend(s)";
case SheetMetal_HBT_Teardrop: return "Teardrop Hem Bend(s)";
case SheetMetal_HBT_Rope: return "Rope Hem Bend(s)";
case SheetMetal_HBT_Rolled: return "Rolled Hem Bend(s)";
default:
break;
}
return "Hem Bend(s)";
}
const char* BendName (const SheetMetal_Bend& theBend)
{
if (theBend.IsOfType<SheetMetal_HemBend>()) {
const auto& aHemBend = static_cast <const SheetMetal_HemBend&> (theBend);
return HemTypeToString (aHemBend.Type());
} else if (theBend.IsOfType<SheetMetal_CurvedBend>()) {
return "Curved Bend(s)";
}
return "Bend(s)";
}
const char* BendColor (const SheetMetal_Bend& theBend)
{
if (theBend.IsOfType<SheetMetal_HemBend>()) {
const auto& aType = static_cast <const SheetMetal_HemBend&> (theBend).Type();
switch (aType) {
case SheetMetal_HBT_Flattened: return "(22, 65, 124)";
case SheetMetal_HBT_Open: return "(42, 85, 144)";
case SheetMetal_HBT_Teardrop: return "(62, 105, 164)";
case SheetMetal_HBT_Rope: return "(82, 125, 184)";
case SheetMetal_HBT_Rolled: return "(102, 145, 204)";
default:
break;
}
return "(0, 0, 0)";
} else if (theBend.IsOfType<SheetMetal_CurvedBend>()) {
return "(255, 254, 145)";
}
return "(0, 35, 245)";
}
const char* SheetMetalHoleName (const SheetMetal_Hole& theHole)
{
if (theHole.IsOfType<SheetMetal_ComplexHole>()) {
return "Complex Hole(s)";
}
return "Hole(s)";
}
const char* SheetMetalHoleColor (const SheetMetal_Hole& theHole)
{
if (theHole.IsOfType<SheetMetal_ComplexHole>()) {
return "(115, 43, 245)";
}
return "(129, 127, 38)";
}
const char* SmallDistanceIssueName (const DFMSheetMetal_SmallDistanceBetweenFeaturesIssue& theIssue)
{
return "Small Distance Between Bend And Louver Issue(s)";
return "Small Distance Between Extruded Hole And Bend Issue(s)";
return "Small Distance Between Extruded Hole And Edge Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue>()) {
return "Small Distance Between Extruded Holes Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue>()) {
return "Small Distance Between Hole And Bend Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue>()) {
return "Small Distance Between Hole And Cutout Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue>()) {
return "Small Distance Between Hole And Edge Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue>()) {
return "Small Distance Between Hole And Louver Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue>()) {
return "Small Distance Between Hole And Notch Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHolesIssue>()) {
return "Small Distance Between Holes Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue>()) {
return "Small Distance Between Notch And Bend Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchesIssue>()) {
return "Small Distance Between Notches Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenTabsIssue>()) {
return "Small Distance Between Tabs Issue(s)";
}
return "Small Distance Between Feature(s)";
}
const char* SmallDistanceIssueColor (const DFMSheetMetal_SmallDistanceBetweenFeaturesIssue& theIssue)
{
return "(195, 56, 19)";
return "(212, 75, 90)";
return "(198, 75, 105)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue>()) {
return "(170, 65, 120)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue>()) {
return "(239, 136, 190)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue>()) {
return "(127, 130, 187)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue>()) {
return "(240, 135, 132)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue>()) {
return "(15, 5, 129)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue>()) {
return "(235, 51, 36)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHolesIssue>()) {
return "(142, 64, 58)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue>()) {
return "(58, 6, 3)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchesIssue>()) {
return "(0, 215, 3)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenTabsIssue>()) {
return "(157, 160, 207)";
}
return "(0, 0, 0)";
}
void AddShapeFeature (FeatureGroupManager& theManager,
const MTKBase_ShapeFeature& theFeature,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
const auto& aFeature = theFeature;
//machining
if (aFeature.IsOfType<Machining_TurningFace>()) {
const auto& aTurningFace = static_cast<const Machining_TurningFace&> (aFeature);
auto aType = aTurningFace.Type();
auto aFeatureData = WriteFeatureDataToString ("Radius", "mm", aTurningFace.Radius(), theShapeIdVector);
theManager.AddGroupData (MachiningFaceTypeToString (aType), MachiningFaceColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_Face>()) {
auto& aFace = static_cast<const Machining_Face&> (aFeature);
auto aType = aFace.Type();
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData (MachiningFaceTypeToString (aType), MachiningFaceColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_Countersink>()) {
const auto& aCountersink = static_cast<const Machining_Countersink&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aCountersink.Radius(),
"Depth", "mm", aCountersink.Depth(),
"Axis", "", aCountersink.Axis().Axis(),
theShapeIdVector);
theManager.AddGroupData ("Countersink(s)", "(55, 125, 34)", aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_Hole>()) {
const auto& aHole = static_cast<const Machining_Hole&> (aFeature);
auto aType = aHole.Type();
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aHole.Radius(),
"Depth", "mm", aHole.Depth(),
"Axis", "", aHole.Axis().Axis(),
theShapeIdVector);
theManager.AddGroupData (MachiningHoleTypeToString (aType), MachiningHoleColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_Pocket>()) {
const auto& aPocket = static_cast<const Machining_Pocket&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aPocket.Length(),
"Width", "mm", aPocket.Width(),
"Depth", "mm", aPocket.Depth(),
"Axis", "", aPocket.Axis().Direction(),
theShapeIdVector);
theManager.AddGroupData ("Pocket(s)", "(23, 63, 63)", aFeatureData, theCount);
} else if (aFeature.IsOfType<MTKBase_Boss>()) {
const auto& aBoss = static_cast<const MTKBase_Boss&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aBoss.Length(),
"Width", "mm", aBoss.Width(),
"Height", "mm", aBoss.Height(),
theShapeIdVector);
theManager.AddGroupData ("Boss(es)", "(56, 72, 13)", aFeatureData, theCount);
}
//sheet metal
else if (aFeature.IsOfType<SheetMetal_Bead>()) {
const auto& aBead = static_cast<const SheetMetal_Bead&> (aFeature);
auto aFeatureData = WriteFeatureDataToString ("Depth", "mm", aBead.Depth(), theShapeIdVector);
theManager.AddGroupData ("Bead(s)", "(115, 251, 253)", aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Bend>()) {
const auto& aBend = static_cast<const SheetMetal_Bend&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aBend.Radius(),
"Angle", "deg", aBend.Angle() * 180 / M_PI,
"Length", "mm", aBend.Length(),
"Width", "mm", aBend.Width(),
theShapeIdVector);
theManager.AddGroupData (BendName (aBend), BendColor (aBend), aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Bridge>()) {
const auto& aBridge = static_cast<const SheetMetal_Bridge&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aBridge.Length(),
"Depth", "mm", aBridge.Depth(),
theShapeIdVector);
theManager.AddGroupData ("Bridge(s)", "(240, 155, 89)", aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Hole>()) {
const auto& aHole = static_cast<const SheetMetal_Hole&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aHole.Radius(),
"Depth", "mm", aHole.Depth(),
"Axis", "", aHole.Axis().Axis(),
theShapeIdVector);
theManager.AddGroupData (SheetMetalHoleName (aHole), SheetMetalHoleColor (aHole), aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Cutout>()) {
const auto& aCutout = static_cast<const SheetMetal_Cutout&> (aFeature);
auto aFeatureData = WriteFeatureDataToString ("Perimeter", "mm", aCutout.Perimeter(), theShapeIdVector);
theManager.AddGroupData ("Cutout(s)", "(88, 19, 94)", aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Louver>()) {
const auto& aLouver = static_cast<const SheetMetal_Louver&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Depth", "mm", aLouver.Depth(),
theShapeIdVector);
theManager.AddGroupData ("Louver(s)", "(161, 251, 142)", aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Notch>()) {
const auto& aNotch = static_cast<const SheetMetal_Notch&> (aFeature);
if (aNotch.IsOfType<SheetMetal_StraightNotch>()) {
const auto& aStraightNotch = static_cast<const SheetMetal_StraightNotch&> (aNotch);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aNotch.Length(),
"Width", "mm", aNotch.Width(),
"Corner Fillet Radius", "mm", aStraightNotch.CornerFilletRadius(),
theShapeIdVector);
theManager.AddGroupData ("Straight Notch(es)", "(240, 135, 132)", aFeatureData, theCount);
} else if (aNotch.IsOfType<SheetMetal_VNotch>()) {
const auto& aVNotch = static_cast<const SheetMetal_VNotch&> (aNotch);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aNotch.Length(),
"Width", "mm", aNotch.Width(),
"Angle", "deg", aVNotch.Angle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("V Notch(es)", "(235, 51, 36)", aFeatureData, theCount);
} else {
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aNotch.Length(),
"Width", "mm", aNotch.Width(),
theShapeIdVector);
theManager.AddGroupData ("Notch(es)", "(239, 136, 190)", aFeatureData, theCount);
}
} else if (aFeature.IsOfType<SheetMetal_Tab>()) {
const auto& aTab = static_cast<const SheetMetal_Tab&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aTab.Length(),
"Width", "mm", aTab.Width(),
theShapeIdVector);
theManager.AddGroupData ("Tab(s)", "(127, 130, 187)", aFeatureData, theCount);
}
}
void AddDrillingIssue (FeatureGroupManager& theManager,
const DFMMachining_DrillingIssue& theIssue,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
if (theIssue.IsOfType<DFMMachining_SmallDiameterHoleIssue>()) {
const auto& aSmallHoleIssue = static_cast<const DFMMachining_SmallDiameterHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Diameter", "mm", aSmallHoleIssue.ExpectedMinDiameter(),
"Actual Diameter", "mm", aSmallHoleIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Small Diameter Hole(s)", "(115, 251, 253)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_DeepHoleIssue>()) {
const auto& aDeepHoleIssue = static_cast<const DFMMachining_DeepHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Depth", "mm", aDeepHoleIssue.ExpectedMaxDepth(),
"Actual Depth", "mm", aDeepHoleIssue.ActualDepth(),
theShapeIdVector);
theManager.AddGroupData ("Deep Hole(s)", "(0, 35, 245)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonStandardDiameterHoleIssue>()) {
const auto& aNSDiameterHoleIssue = static_cast<const DFMMachining_NonStandardDiameterHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Diameter", "mm", aNSDiameterHoleIssue.NearestStandardDiameter(),
"Actual Diameter", "mm", aNSDiameterHoleIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Non Standard Diameter Hole(s)", "(22, 65, 124)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonStandardDrillPointAngleBlindHoleIssue>()) {
const auto& aNSDrillPointAngleBlindHoleIssue = static_cast<const DFMMachining_NonStandardDrillPointAngleBlindHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Angle", "deg", aNSDrillPointAngleBlindHoleIssue.NearestStandardAngle() * 180 / M_PI,
"Actual Angle", "deg", aNSDrillPointAngleBlindHoleIssue.ActualAngle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Non Standard Drill Point Angle Blind Hole(s)", "(88, 13, 78)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_PartialHoleIssue>()) {
const auto& aPartialHoleIssue = static_cast<const DFMMachining_PartialHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Material Percent", "%", aPartialHoleIssue.ExpectedMinMaterialPercent() * 100,
"Actual Material Percent", "%", aPartialHoleIssue.ActualMaterialPercent() * 100,
theShapeIdVector);
theManager.AddGroupData ("Partial Hole(s)", "(255, 254, 145)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_FlatBottomHoleIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Flat Bottom Hole(s)", "(240, 155, 89)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonPerpendicularHoleIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Non Perpendicular Hole(s)", "(129, 127, 38)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_IntersectingCavityHoleIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Intersecting Cavity Hole(s)", "(115, 43, 245)", aFeatureData, theCount);
}
}
void AddMillingIssue (FeatureGroupManager& theManager,
const DFMMachining_MillingIssue& theIssue,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
const auto& aFloorRadiusIssue = static_cast<const DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Radius", "mm", aFloorRadiusIssue.NearestStandardRadius(),
"Actual Radius", "mm", aFloorRadiusIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Non Standard Radius Milled Part Floor Fillet Issue(s)", "(0, 215, 3)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_DeepPocketIssue>()) {
const auto& aDeepPocketIssue = static_cast<const DFMMachining_DeepPocketIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Depth", "mm", aDeepPocketIssue.ExpectedMaxDepth(),
"Actual Depth", "mm", aDeepPocketIssue.ActualDepth(),
theShapeIdVector);
theManager.AddGroupData ("Deep Pocket Issue(s)", "(190, 10, 100)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_HighBossIssue>()) {
const auto& aHighBossIssue = static_cast<const DFMMachining_HighBossIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Height", "mm", aHighBossIssue.ExpectedMaxHeight(),
"Actual Height", "mm", aHighBossIssue.ActualHeight(),
theShapeIdVector);
theManager.AddGroupData ("High Boss Issue(s)", "(180, 100, 50)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_LargeMilledPartIssue>()) {
const auto& aLMPIssue = static_cast<const DFMMachining_LargeMilledPartIssue&> (theIssue);
const auto& anExpectedSize = aLMPIssue.ExpectedMaxMilledPartSize();
const auto& anActualSize = aLMPIssue.ActualMilledPartSize();
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Size (LxWxH)", "mm",
ArrayType ({ anExpectedSize.Length(), anExpectedSize.Width(), anExpectedSize.Height() }),
"Actual Size (LxWxH)", "mm",
ArrayType ({ anActualSize.Length(), anActualSize.Width(), anActualSize.Height() }),
theShapeIdVector);
theManager.AddGroupData ("Large Milled Part(s)", "(17, 37, 205)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_SmallRadiusMilledPartInternalCornerIssue>()) {
const auto& aMSICRIssue = static_cast<const DFMMachining_SmallRadiusMilledPartInternalCornerIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Radius", "mm", aMSICRIssue.ExpectedMinRadius(),
"Actual Radius", "mm", aMSICRIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData (
"Small Radius Milled Part Internal Corner(s)", "(10, 10, 200)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonPerpendicularMilledPartShapeIssue>()) {
const auto& aNPMPSIssue = static_cast<const DFMMachining_NonPerpendicularMilledPartShapeIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Actual Angle", "deg", aNPMPSIssue.ActualAngle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Non Perpendicular Milled Part Shape(s)", "(129, 227, 138)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_MilledPartExternalEdgeFilletIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Milled Part External Edge Fillet(s)", "(201, 227, 13)", aFeatureData, theCount);
const auto& anInconsistentRadiusIssue =
auto aFeatureData = WriteFeatureDataToString (
"Expected Radius", "mm", anInconsistentRadiusIssue.ExpectedRadius(),
"Actual Radius", "mm", anInconsistentRadiusIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Inconsistent Radius Milled Part Floor Fillet Issue(s)", "(180, 15, 190)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NarrowRegionInPocketIssue>()) {
const auto& aNarrowRegionIssue =
static_cast<const DFMMachining_NarrowRegionInPocketIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Region Size", "mm", aNarrowRegionIssue.ExpectedMinRegionSize(),
"Actual Region Size", "mm", aNarrowRegionIssue.ActualRegionSize(),
theShapeIdVector);
theManager.AddGroupData ("Narrow Region In Pocket Issue(s)", "(70, 150, 150)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_LargeDifferenceRegionsSizeInPocketIssue>()) {
const auto& aLargeRatioIssue =
auto aFeatureData = WriteFeatureDataToString (
"Expected Regions Maximum To Minimum Size Ratio", "", aLargeRatioIssue.ExpectedMaxRegionsMaxToMinSizeRatio(),
"Actual Regions Maximum To Minimum Size Ratio", "", aLargeRatioIssue.ActualMaxRegionsMaxToMinSizeRatio(),
theShapeIdVector);
theManager.AddGroupData ("Large Difference Regions Size In Pocket Issue(s)", "(100, 150, 150)", aFeatureData, theCount);
}
}
void AddTurningIssue (FeatureGroupManager& theManager,
const DFMBase_Issue& theIssue,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
if (theIssue.IsOfType<DFMMachining_LargeTurnedPartIssue>()) {
const auto& aLTSIssue = static_cast<const DFMMachining_LargeTurnedPartIssue&> (theIssue);
const auto& anExpectedSize = aLTSIssue.ExpectedMaxTurnedPartSize();
const auto& anActualSize = aLTSIssue.ActualTurnedPartSize();
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Size (LxR)", "mm", std::make_pair (anExpectedSize.Length(), anExpectedSize.Radius()),
"Actual Size (LxR)", "mm", std::make_pair (anActualSize.Length(), anActualSize.Radius()),
theShapeIdVector);
theManager.AddGroupData ("Large Turned Part(s)", "(195, 195, 195)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_LongSlenderTurnedPartIssue>()) {
const auto& aLSTIssue = static_cast<const DFMMachining_LongSlenderTurnedPartIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Length", "mm", aLSTIssue.ExpectedMaxLength(),
"Actual Length", "mm", aLSTIssue.ActualLength(),
"Actual Minimum Diameter", "mm", aLSTIssue.ActualMinDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Long-Slender Turned Part(s)", "(195, 195, 195)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_SmallDepthBlindBoredHoleReliefIssue>()) {
const auto& aBBHRIssue = static_cast<const DFMMachining_SmallDepthBlindBoredHoleReliefIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Relief Depth", "mm", aBBHRIssue.ExpectedMinReliefDepth(),
"Actual Relief Depth", "mm", aBBHRIssue.ActualReliefDepth(),
"Actual Diameter", "mm", aBBHRIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Small Depth Blind Bored Hole Relief(s)", "(88, 19, 94)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_DeepBoredHoleIssue>()) {
const auto& aISBHIssue = static_cast<const DFMMachining_DeepBoredHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Depth", "mm", aISBHIssue.ExpectedMaxDepth(),
"Actual Depth", "mm", aISBHIssue.ActualDepth(),
"Actual Diameter", "mm", aISBHIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Deep Bored Hole(s)", "(161, 251, 142)", aFeatureData, theCount);
const auto& aODPRIssue = static_cast<const DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Face Incline Angle", "deg", aODPRIssue.ExpectedMaxFaceInclineAngle() * 180 / M_PI,
"Actual Face Incline Angle", "deg", aODPRIssue.ActualFaceInclineAngle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Irregular Turned Part Outer Diameter Profile Relief(s)", "(239, 136, 190)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_SmallRadiusTurnedPartInternalCornerIssue>()) {
const auto& aTSICRIssue = static_cast<const DFMMachining_SmallRadiusTurnedPartInternalCornerIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Radius", "mm", aTSICRIssue.ExpectedMinRadius(),
"Actual Radius", "mm", aTSICRIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Small Radius Turned Part Internal Corner(s)", "(127, 130, 187)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_SquareEndKeywayIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Square End Keyway(s)", "(157, 160, 207)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonSymmetricalAxialSlotIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Non Symmetrical Axial Slot(s)", "(130, 170, 200)", aFeatureData, theCount);
}
}
void AddSheetMetalIssue (FeatureGroupManager& theManager,
const DFMBase_Issue& theIssue,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
if (theIssue.IsOfType<DFMSheetMetal_FlatPatternInterferenceIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Flat Pattern Interference(s)", "(115, 251, 253)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue>()) {
const auto& aICFRNIssue = static_cast<const DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Corner Fillet Radius", "mm", aICFRNIssue.ExpectedCornerFilletRadius(),
"Actual Corner Fillet Radius", "mm", aICFRNIssue.ActualCornerFilletRadius(),
theShapeIdVector);
theManager.AddGroupData ("Irregular Corner Fillet Radius Notch(es)", "(239, 136, 190)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularDepthExtrudedHoleIssue>()) {
const auto& aIDEHIssue = static_cast<const DFMSheetMetal_IrregularDepthExtrudedHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Extruded Height", "mm", aIDEHIssue.ExpectedMaxExtrudedHeight(),
"Expected Minimum Extruded Height", "mm", aIDEHIssue.ExpectedMinExtrudedHeight(),
"Actual Extruded Height", "mm", aIDEHIssue.ActualExtrudedHeight(),
theShapeIdVector);
theManager.AddGroupData ("Irregular depth extruded Hole(s)", "(50, 120, 210)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularRadiusOpenHemBendIssue>()) {
const auto& aIROHBIssue = static_cast<const DFMSheetMetal_IrregularRadiusOpenHemBendIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Radius", "mm", aIROHBIssue.ExpectedRadius(),
"Actual Radius", "mm", aIROHBIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Irregular Radius Open Hem Bend(s)", "(188, 121, 11)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_InconsistentRadiusBendIssue>()) {
const auto& aIRBIssue = static_cast<const DFMSheetMetal_InconsistentRadiusBendIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Radius", "mm", aIRBIssue.ExpectedRadius(),
"Actual Radius", "mm", aIRBIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Inconsistent Radius Bend(s)", "(0, 35, 245)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularSizeBendReliefIssue>()) {
const auto& aISBRIssue = static_cast<const DFMSheetMetal_IrregularSizeBendReliefIssue&> (theIssue);
const auto& anExpectedRelief = aISBRIssue.ExpectedMinBendRelief();
const auto& aFirstActualRelief = aISBRIssue.FirstActualRelief();
const auto& aSecondActualRelief = aISBRIssue.SecondActualRelief();
std::string aFeatureData;
if (aFirstActualRelief && aSecondActualRelief) {
aFeatureData = WriteFeatureDataToString (
"Expected Minimum Relief Size (LxW)", "mm", std::make_pair (anExpectedRelief.Length(), anExpectedRelief.Width()),
"First Actual Relief Size (LxW)", "mm", std::make_pair (aFirstActualRelief.Length(), aFirstActualRelief.Width()),
"Second Actual Relief Size (LxW)", "mm", std::make_pair (aSecondActualRelief.Length(), aSecondActualRelief.Width()),
theShapeIdVector);
} else if (!aFirstActualRelief) {
aFeatureData = WriteFeatureDataToString (
"Expected Minimum Relief Size (LxW)", "mm", std::make_pair (anExpectedRelief.Length(), anExpectedRelief.Width()),
"Actual Relief Size (LxW)", "mm", std::make_pair (aSecondActualRelief.Length(), aSecondActualRelief.Width()),
theShapeIdVector);
} else {
aFeatureData = WriteFeatureDataToString (
"Expected Minimum Relief Size (LxW)", "mm", std::make_pair (anExpectedRelief.Length(), anExpectedRelief.Width()),
"Actual Relief Size (LxW)", "mm", std::make_pair (aFirstActualRelief.Length(), aFirstActualRelief.Width()),
theShapeIdVector);
}
theManager.AddGroupData ("Irregular Size Bend Relief(s)", "(22, 65, 124)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularSizeNotchIssue>()) {
const auto& aISNIssue = static_cast<const DFMSheetMetal_IrregularSizeNotchIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Size (LxW)", "mm", std::make_pair (aISNIssue.ExpectedLength(), aISNIssue.ExpectedWidth()),
"Actual Size (LxW)", "mm", std::make_pair (aISNIssue.ActualLength(), aISNIssue.ActualWidth()),
theShapeIdVector);
theManager.AddGroupData ("Irregular Size Notch(s)", "(255, 254, 145)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularSizeTabIssue>()) {
const auto& aISTIssue = static_cast<const DFMSheetMetal_IrregularSizeTabIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Size (LxW)", "mm", std::make_pair (aISTIssue.ExpectedLength(), aISTIssue.ExpectedWidth()),
"Actual Size (LxW)", "mm", std::make_pair (aISTIssue.ActualLength(), aISTIssue.ActualWidth()),
theShapeIdVector);
theManager.AddGroupData ("Irregular Size Tab(s)", "(240, 155, 89)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_LargeDepthBeadIssue>()) {
const auto& aLDBIssue = static_cast<const DFMSheetMetal_LargeDepthBeadIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Depth", "mm", aLDBIssue.ExpectedMaxDepth(),
"Actual Depth", "mm", aLDBIssue.ActualDepth(),
theShapeIdVector);
theManager.AddGroupData ("Large Depth Bead(s)", "(129, 127, 38)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDepthLouverIssue>()) {
const auto& aSDLIssue = static_cast<const DFMSheetMetal_SmallDepthLouverIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Depth", "mm", aSDLIssue.ExpectedMinDepth(),
"Actual Depth", "mm", aSDLIssue.ActualDepth(),
theShapeIdVector);
theManager.AddGroupData ("Small Depth Louver(s)", "(190, 127, 58)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_NonStandardSheetSizeIssue>()) {
const auto& aNSSSIssue = static_cast<const DFMSheetMetal_NonStandardSheetSizeIssue&> (theIssue);
const auto& aNesrestStandardSize = aNSSSIssue.NearestStandardSheetSize();
const auto& anActualSize = aNSSSIssue.ActualSheetSize();
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Size (LxW)", "mm", std::make_pair (aNesrestStandardSize.Length(), aNesrestStandardSize.Width()),
"Actual Size (LxW)", "mm", std::make_pair (anActualSize.Length(), anActualSize.Width()),
theShapeIdVector);
theManager.AddGroupData ("Non Standard Sheet Size(s)", "(0, 0, 0)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_NonStandardSheetThicknessIssue>()) {
const auto& aNSSTIssue = static_cast<const DFMSheetMetal_NonStandardSheetThicknessIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Thickness", "mm", aNSSTIssue.NearestStandardSheetThickness(),
"Actual Thickness", "mm", aNSSTIssue.ActualSheetThickness(),
theShapeIdVector);
theManager.AddGroupData ("Non Standard Sheet Thickness(s)", "(0, 0, 0)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDiameterHoleIssue>()) {
const auto& aSDHIssue = static_cast<const DFMSheetMetal_SmallDiameterHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Diameter", "mm", aSDHIssue.ExpectedMinDiameter(),
"Actual Diameter", "mm", aSDHIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Small Diameter Hole(s)", "(115, 43, 245)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallLengthFlangeIssue>()) {
const auto& aSLFIssue = static_cast<const DFMSheetMetal_SmallLengthFlangeIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Length", "mm", aSLFIssue.ExpectedMinLength(),
"Actual Length", "mm", aSLFIssue.ActualLength(),
theShapeIdVector);
theManager.AddGroupData ("Small Length Flange(s)", "(88, 19, 94)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallLengthHemBendFlangeIssue>()) {
const auto& aSLFIssue = static_cast<const DFMSheetMetal_SmallLengthHemBendFlangeIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Length", "mm", aSLFIssue.ExpectedMinLength(),
"Actual Length", "mm", aSLFIssue.ActualLength(),
theShapeIdVector);
theManager.AddGroupData ("Small Length Hem Bend Flange(s)", "(70, 139, 51)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallRadiusBendIssue>()) {
const auto& aSRBIssue = static_cast<const DFMSheetMetal_SmallRadiusBendIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Radius", "mm", aSRBIssue.ExpectedMinRadius(),
"Actual Radius", "mm", aSRBIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Small Radius Bend(s)", "(161, 251, 142)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenFeaturesIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenFeaturesIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Distance", "mm", aSDIssue.ExpectedMinDistanceBetweenFeatures(),
"Actual Distance", "mm", aSDIssue.ActualDistanceBetweenFeatures(),
theShapeIdVector);
theManager.AddGroupData (SmallDistanceIssueName (aSDIssue), SmallDistanceIssueColor (aSDIssue), aFeatureData, theCount);
}
}
ShapeIDVectorType GetShapesId (const ModelData_Shape& theShape,
{
ShapeIDVectorType aShapeIdVector;
ModelData_Shape::Iterator aShapeIt (theShape, theType);
for (; aShapeIt.HasNext();) {
const auto& aShape = aShapeIt.Next();
aShapeIdVector.push_back (theBRep.ShapeId (aShape));
}
return aShapeIdVector;
}
void AddShapesId (const ModelData_Shape& theShape,
ShapeIDVectorType& theShapesIdVec)
{
ModelData_Shape::Iterator aShapeIt (theShape, theType);
for (; aShapeIt.HasNext();) {
const auto& aShape = aShapeIt.Next();
theShapesIdVec.push_back (theBRep.ShapeId (aShape));
}
}
void SortFeatures (const MTKBase_FeatureList& theFeatures,
FeatureMapType& theMap)
{
for (size_t i = 0; i < theFeatures.Size(); i++) {
const auto& aFeature = theFeatures[i];
if (aFeature.IsOfType<MTKBase_CompositeFeature>()) {
const auto& aCompositeFeature = static_cast<const MTKBase_CompositeFeature&> (aFeature);
SortFeatures (aCompositeFeature.FeatureList(), theBRep, theMap);
continue;
}
auto& anElement = theMap[aFeature];
++anElement.first;
//features
if (aFeature.IsOfType<MTKBase_ShapeFeature>()) {
const auto& aShapeFeature = static_cast<const MTKBase_ShapeFeature&> (aFeature);
ModelData_ShapeType aShapeType = ModelData_ST_Face;
if (aFeature.IsOfType<SheetMetal_Cutout>()
|| (aFeature.IsOfType<SheetMetal_Hole>() && !aFeature.IsOfType<SheetMetal_ComplexHole>())
|| aFeature.IsOfType<SheetMetal_Notch>() || aFeature.IsOfType<SheetMetal_Tab>()) {
aShapeType = ModelData_ST_Edge;
}
auto aShapeIdVector = GetShapesId (aShapeFeature.Shape(), theBRep, aShapeType);
anElement.second.push_back (aShapeIdVector);
}
//dfm machining drilling
else if (aFeature.IsOfType<DFMMachining_DrillingIssue>()){
const auto& anIssue = static_cast<const DFMMachining_DrillingIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (anIssue.Hole().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
}
//dfm machining milling
const auto& aNSRMPFFIssue = static_cast<const DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aNSRMPFFIssue.FloorFillet(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_DeepPocketIssue>()) {
const auto& aDCIssue = static_cast<const DFMMachining_DeepPocketIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aDCIssue.Pocket().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_HighBossIssue>()) {
const auto& aHBIssue = static_cast<const DFMMachining_HighBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aHBIssue.Boss().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_LargeMilledPartIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
} else if (aFeature.IsOfType<DFMMachining_SmallRadiusMilledPartInternalCornerIssue>()) {
const auto& aMSICRIssue = static_cast<const DFMMachining_SmallRadiusMilledPartInternalCornerIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aMSICRIssue.Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_NonPerpendicularMilledPartShapeIssue>()) {
const auto& aNPMPSIssue = static_cast<const DFMMachining_NonPerpendicularMilledPartShapeIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aNPMPSIssue.Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_MilledPartExternalEdgeFilletIssue>()) {
const auto& aMPEEFIssue = static_cast<const DFMMachining_MilledPartExternalEdgeFilletIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aMPEEFIssue.Fillet(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
const auto& aIRMPFFIssue = static_cast<const DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIRMPFFIssue.FloorFillet(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_NarrowRegionInPocketIssue>()) {
const auto& aNRIPIssue = static_cast<const DFMMachining_NarrowRegionInPocketIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aNRIPIssue.InnerFeature(), theBRep, ModelData_ST_Face, aShapeIdVector);
AddShapesId (aNRIPIssue.NarrowRegionSidewall(), theBRep, ModelData_ST_Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_LargeDifferenceRegionsSizeInPocketIssue>()) {
const auto& aLDRSIPIssue = static_cast<const DFMMachining_LargeDifferenceRegionsSizeInPocketIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aLDRSIPIssue.InnerFeature(), theBRep, ModelData_ST_Face, aShapeIdVector);
AddShapesId (aLDRSIPIssue.MinRegionPocketSidewall(), theBRep, ModelData_ST_Face, aShapeIdVector);
AddShapesId (aLDRSIPIssue.MaxRegionPocketSidewall(), theBRep, ModelData_ST_Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
}
//dfm machining turning
else if (aFeature.IsOfType<DFMMachining_SmallDepthBlindBoredHoleReliefIssue>()) {
const auto& aBBHRIssue = static_cast<const DFMMachining_SmallDepthBlindBoredHoleReliefIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aBBHRIssue.BlindBoredHole(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_DeepBoredHoleIssue>()) {
const auto& aISBHIssue = static_cast<const DFMMachining_DeepBoredHoleIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aISBHIssue.Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
const auto& aODPRIssue = static_cast<const DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aODPRIssue.Face(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_SmallRadiusTurnedPartInternalCornerIssue>()) {
const auto& aTSICRIssue = static_cast<const DFMMachining_SmallRadiusTurnedPartInternalCornerIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aTSICRIssue.Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_SquareEndKeywayIssue>()) {
const auto& aSEKIssue = static_cast<const DFMMachining_SquareEndKeywayIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSEKIssue.Keyway().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_NonSymmetricalAxialSlotIssue>()) {
const auto& aNSASIssue = static_cast<const DFMMachining_NonSymmetricalAxialSlotIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aNSASIssue.AxialSlot().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_LargeTurnedPartIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
} else if (aFeature.IsOfType<DFMMachining_LongSlenderTurnedPartIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
}
//dfm sheet metal
else if (aFeature.IsOfType<DFMSheetMetal_FlatPatternInterferenceIssue>()) {
const auto& aFPIIssue = static_cast<const DFMSheetMetal_FlatPatternInterferenceIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector ({ theBRep.ShapeId (aFPIIssue.FirstFace()),
theBRep.ShapeId (aFPIIssue.SecondFace()) });
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue>()) {
const auto& aICFRNIssue = static_cast<const DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aICFRNIssue.Notch().Shape(), theBRep, ModelData_ST_Edge);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularDepthExtrudedHoleIssue>()) {
const auto& aIDEHIssue = static_cast<const DFMSheetMetal_IrregularDepthExtrudedHoleIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIDEHIssue.Hole().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularRadiusOpenHemBendIssue>()) {
const auto& aIROHBIssue = static_cast<const DFMSheetMetal_IrregularRadiusOpenHemBendIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIROHBIssue.Bend().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_InconsistentRadiusBendIssue>()) {
const auto& aIRBIssue = static_cast<const DFMSheetMetal_InconsistentRadiusBendIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIRBIssue.Bend().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularSizeBendReliefIssue>()) {
const auto& aISBRIssue = static_cast<const DFMSheetMetal_IrregularSizeBendReliefIssue&> (aFeature);
const auto& aFirstActualRelief = aISBRIssue.FirstActualRelief();
const auto& aSecondActualRelief = aISBRIssue.SecondActualRelief();
ShapeIDVectorType aShapeIdVector;
AddShapesId (aISBRIssue.Bend().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
if (aFirstActualRelief) {
AddShapesId (aFirstActualRelief.Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
}
if (aSecondActualRelief) {
AddShapesId (aSecondActualRelief.Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
}
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularSizeNotchIssue>()) {
const auto& aISNIssue = static_cast<const DFMSheetMetal_IrregularSizeNotchIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aISNIssue.Notch().Shape(), theBRep, ModelData_ST_Edge);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularSizeTabIssue>()) {
const auto& aISTIssue = static_cast<const DFMSheetMetal_IrregularSizeTabIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aISTIssue.Tab().Shape(), theBRep, ModelData_ST_Edge);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_LargeDepthBeadIssue>()) {
const auto& aLDBIssue = static_cast<const DFMSheetMetal_LargeDepthBeadIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aLDBIssue.Bead().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDepthLouverIssue>()) {
const auto& aSDLIssue = static_cast<const DFMSheetMetal_SmallDepthLouverIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSDLIssue.Louver().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_NonStandardSheetSizeIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
} else if (aFeature.IsOfType<DFMSheetMetal_NonStandardSheetThicknessIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDiameterHoleIssue>()) {
const auto& aSDHIssue = static_cast<const DFMSheetMetal_SmallDiameterHoleIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSDHIssue.Hole().Shape(), theBRep, ModelData_ST_Edge);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallLengthFlangeIssue>()) {
const auto& aSLFIssue = static_cast<const DFMSheetMetal_SmallLengthFlangeIssue&> (aFeature);
const auto& aFlange = aSLFIssue.Flange().FeatureList();
ShapeIDVectorType aShapeIdVector;
for (size_t j = 0; j < aFlange.Size(); j++) {
const auto& aFlangeFace = aFlange[j];
if (aFlangeFace.IsOfType<MTKBase_ShapeFeature>()) {
const auto& aShapeFeature = static_cast<const MTKBase_ShapeFeature&> (aFlangeFace);
AddShapesId (aShapeFeature.Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
}
}
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallLengthHemBendFlangeIssue>()) {
const auto& aSLFIssue = static_cast<const DFMSheetMetal_SmallLengthHemBendFlangeIssue&> (aFeature);
const auto& aFlange = aSLFIssue.Flange().FeatureList();
ShapeIDVectorType aShapeIdVector;
for (size_t j = 0; j < aFlange.Size(); j++) {
const auto& aFlangeFace = aFlange[j];
if (aFlangeFace.IsOfType<MTKBase_ShapeFeature>()) {
const auto& aShapeFeature = static_cast<const MTKBase_ShapeFeature&> (aFlangeFace);
AddShapesId (aShapeFeature.Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
}
}
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallRadiusBendIssue>()) {
const auto& aSRBIssue = static_cast<const DFMSheetMetal_SmallRadiusBendIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSRBIssue.Bend().Shape(), theBRep, ModelData_ST_Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Bend().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
AddShapesId (aSDIssue.Louver().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
AddShapesId (aSDIssue.Bend().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
aShapeIdVector.push_back (theBRep.ShapeId (aSDIssue.Edge()));
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.FirstHole().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
AddShapesId (aSDIssue.SecondHole().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
AddShapesId (aSDIssue.Bend().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
AddShapesId (aSDIssue.Cutout().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
aShapeIdVector.push_back (theBRep.ShapeId (aSDIssue.Edge()));
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
AddShapesId (aSDIssue.Louver().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
AddShapesId (aSDIssue.Notch().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHolesIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHolesIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.FirstHole().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
AddShapesId (aSDIssue.SecondHole().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Notch().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
AddShapesId (aSDIssue.Bend().Shape(), theBRep, ModelData_ST_Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchesIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenNotchesIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.FirstNotch().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
AddShapesId (aSDIssue.SecondNotch().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenTabsIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenTabsIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.FirstTab().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
AddShapesId (aSDIssue.SecondTab().Shape(), theBRep, ModelData_ST_Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
}
}
}
bool WriteFeatures (JSONWriter& theWriter,
const char* theGroupName,
const char* theSubgroupName,
const MTKBase_FeatureList& theFeatures,
const char* theMessageForEmptyList)
{
theWriter.OpenSection (theSubgroupName);
theWriter.WriteData ("name", theGroupName);
if (theFeatures.IsEmpty()) {
theWriter.WriteData ("message", theMessageForEmptyList);
} else {
FeatureMapType aSortedFeatures;
SortFeatures (theFeatures, theBRep, aSortedFeatures);
FeatureGroupManager aFGManager;
for (const auto& i : aSortedFeatures) {
const auto& aFeature = i.first;
size_t aCount = i.second.first;
const auto& aShapeIDVec = i.second.second;
if (aFeature.IsOfType<MTKBase_ShapeFeature>()) {
AddShapeFeature (aFGManager, static_cast<const MTKBase_ShapeFeature&> (aFeature), aCount, aShapeIDVec);
} else if (aFeature.IsOfType<DFMMachining_DrillingIssue>()) {
AddDrillingIssue (aFGManager, static_cast<const DFMMachining_DrillingIssue&> (aFeature), aCount, aShapeIDVec);
} else if (aFeature.IsOfType<DFMMachining_MillingIssue>()) {
AddMillingIssue (aFGManager, static_cast<const DFMMachining_MillingIssue&> (aFeature), aCount, aShapeIDVec);
} else if (aFeature.IsOfType<DFMSheetMetal_BendIssue>()
|| aFeature.IsOfType<DFMSheetMetal_HoleIssue>()
|| aFeature.IsOfType<DFMSheetMetal_IrregularSizeNotchIssue>()
|| aFeature.IsOfType<DFMSheetMetal_IrregularSizeTabIssue>()
|| aFeature.IsOfType<DFMSheetMetal_LargeDepthBeadIssue>()
|| aFeature.IsOfType<DFMSheetMetal_SmallDepthLouverIssue>()
AddSheetMetalIssue (aFGManager, static_cast<const DFMBase_Issue&> (aFeature), aCount, aShapeIDVec);
} else if (aFeature.IsOfType<DFMBase_Issue>()) {
AddTurningIssue (aFGManager, static_cast<const DFMBase_Issue&> (aFeature), aCount, aShapeIDVec);
}
}
theWriter.WriteData ("totalFeatureCount", aFGManager.TotalFeatureCount());
theWriter.OpenArraySection ("featureGroups");
aFGManager.Write (theWriter);
theWriter.CloseArraySection();
}
theWriter.CloseSection();
return true;
}
const char* MachiningProcessName (Machining_OperationType theOperation)
{
switch (theOperation) {
case Machining_OT_Milling: return "CNC Machining Milling";
case Machining_OT_LatheMilling: return "CNC Machining Lathe+Milling";
default:
break;
}
return "CNC Machining";
}
bool HasShapes (const ModelData_BRepRepresentation& theBRep, ModelData_ShapeType theType)
{
const auto& aBodyList = theBRep.Get();
for (size_t i = 0, n = aBodyList.Size(); i < n; ++i) {
const auto& aBody = aBodyList[i];
ModelData_Shape::Iterator aShapeIt (aBody, theType);
if (aShapeIt.HasNext()) {
return true;
}
}
return false;
}
void WriteThicknessNode (JSONWriter& theWriter,
const char* theParamName,
double theParamValue,
const PointPairType& thePoints,
const char* theNodeName)
{
std::stringstream aStream;
aStream << std::fixed << std::setprecision (2);
JSONWriter aWriter (aStream, 3);
aWriter.OpenSection (theNodeName);
aWriter.WriteData ("name", theParamName);
aWriter.WriteData ("units", "mm");
aWriter.WriteData ("value", theParamValue);
aWriter.WriteData ("firstPoint", thePoints.first);
aWriter.WriteData ("secondPoint", thePoints.second);
aWriter.CloseSection();
theWriter.WriteRawData (aStream.str());
}
void WriteUnfoldedPartFeatures (JSONWriter& theWriter,
const MTKConverter_UnfoldedPartData& theData)
{
theWriter.OpenSection ("featureRecognitionUnfolded");
theWriter.WriteData ("name", "Feature Recognition");
if (theData.IsInit()) {
std::stringstream aStream;
aStream << std::fixed << std::setprecision (2);
JSONWriter aWriter (aStream, 4);
aWriter.WriteData ("parametersCount", 3);
aWriter.OpenArraySection ("parameters");
const auto& aFlatPattern = theData.myFlatPattern;
WriteParameter (aWriter, "Length", "mm", aFlatPattern.Length());
WriteParameter (aWriter, "Width", "mm", aFlatPattern.Width());
WriteParameter (aWriter, "Thickness", "mm", aFlatPattern.Thickness());
WriteParameter (aWriter, "Perimeter", "mm", aFlatPattern.Perimeter());
aWriter.CloseArraySection();
theWriter.WriteRawData (aStream.str());
} else {
theWriter.WriteData ("message", "Unfolded part wasn't generated.");
}
theWriter.CloseSection();
}
void WritePartProcessData (JSONWriter& theWriter, const DataType& theProcessData)
{
bool aRes = false;
theWriter.WriteData ("partId", theProcessData->myPart.Uuid());
std::string anErrorMsg = "An error occurred while processing the part.";
if (theProcessData) {
if (auto aMD = std::dynamic_pointer_cast<MTKConverter_MachiningData> (theProcessData)) {
theWriter.WriteData ("process", MachiningProcessName (aMD->myOperation));
const auto& aBRep = aMD->myPart.BRepRepresentation();
if (!aMD->myFeatureList.IsEmpty()) {
WriteFeatures (theWriter, "Feature Recognition", "featureRecognition", aMD->myFeatureList, aBRep, "");
WriteFeatures (theWriter, "Design for Manufacturing", "dfm", aMD->myIssueList, aBRep,
"Part contains no DFM improvement suggestions.");
aRes = true;
} else if (!aBRep || !HasShapes (aBRep, ModelData_ST_Solid)) {
anErrorMsg = "The part can't be analyzed due to lack of: "
"BRep representation or solids in BRep representation.";
}
} else if (auto aWTD = std::dynamic_pointer_cast<MTKConverter_WallThicknessData> (theProcessData)) {
theWriter.WriteData ("process", "Wall Thickness Analysis");
const auto& aBRep = aWTD->myPart.BRepRepresentation();
const auto& aPoly = aWTD->myPart.PolyRepresentation (ModelData_RM_Any);
if (aWTD->myIsInit) {
WriteThicknessNode (theWriter, "Minimum Thickness", aWTD->myMinThickness, aWTD->myMinThicknessPoints, "minThickness");
WriteThicknessNode (theWriter, "Maximum Thickness", aWTD->myMaxThickness, aWTD->myMaxThicknessPoints, "maxThickness");
aRes = true;
} else if ((!aBRep || !HasShapes (aBRep, ModelData_ST_Solid)) && !aPoly) {
anErrorMsg = "The part can't be analyzed due to lack of: "
"BRep representation, solids in BRep representation or Poly representations.";
}
} else if (auto aSMD = std::dynamic_pointer_cast<MTKConverter_SheetMetalData> (theProcessData)) {
theWriter.WriteData ("process", "Sheet Metal");
const auto& aBRep = aSMD->myPart.BRepRepresentation();
if (aSMD->myIsSheetMetalPart) {
WriteFeatures (theWriter, "Feature Recognition", "featureRecognition", aSMD->myFeatureList, aBRep,
"Part contains no features.");
WriteFeatures (theWriter, "Design for Manufacturing", "dfm", aSMD->myIssueList, aBRep,
"Part contains no DFM improvement suggestions.");
const auto& anUnfoldedPartData = aSMD->myUnfoldedPartData;
WriteUnfoldedPartFeatures (theWriter, anUnfoldedPartData);
if (anUnfoldedPartData.IsInit()) {
WriteFeatures (theWriter, "Design for Manufacturing", "dfmUnfolded", anUnfoldedPartData.myIssueList,
anUnfoldedPartData.myBRep, "Unfolded part contains no DFM improvement suggestions.");
}
aRes = true;
} else if (!aBRep || (!HasShapes (aBRep, ModelData_ST_Solid) && !HasShapes (aBRep, ModelData_ST_Shell))) {
anErrorMsg = "The part can't be analyzed due to lack of: "
"BRep representation, solids and shells in BRep representation.";
} else {
anErrorMsg = "The part wasn't recognized as a sheet metal part.";
}
} else {
anErrorMsg = "Unrecognized process";
}
}
if (!aRes) {
theWriter.WriteData ("error", anErrorMsg);
}
}
}
bool MTKConverter_Report::WriteToJSON (const Base_UTF16String& thePath) const
{
std::ofstream aFile (thePath.ToUTF8().String().c_str());
if (!aFile) {
return false;
}
JSONWriter aWriter (aFile);
aWriter.OpenSection();
aWriter.WriteData ("version", "1");
if (myData.empty()) {
aWriter.WriteData ("error", "The model doesn't contain any parts.");
} else {
aWriter.OpenArraySection ("parts");
for (const auto& aProcessData : myData) {
aWriter.OpenSection();
WritePartProcessData (aWriter, aProcessData);
aWriter.CloseSection();
}
aWriter.CloseArraySection();
}
aWriter.CloseSection();
return true;
}
const value_type & String() const
Returns an internal string representation.
Definition: Base_String.cxx:134
Base_String ToUTF8() const
Converts to UTF-8 string.
Definition: Base_UTF16String.cxx:138
Describes a base class for issues found during design for manufacturing (DFM) analysis.
Definition: DFMBase_Issue.hxx:32
Describes deep bored hole issue found during cnc machining turning design analysis.
Definition: DFMMachining_DeepBoredHoleIssue.hxx:33
Describes deep hole issues found during cnc machining drilling design analysis.
Definition: DFMMachining_DeepHoleIssue.hxx:31
Describes a base class for drilling issues found during cnc machining drilling design analysis.
Definition: DFMMachining_DrillingIssue.hxx:37
Describes flat bottom hole issues found during cnc machining drilling design analysis.
Definition: DFMMachining_FlatBottomHoleIssue.hxx:31
Describes high boss issues found during cnc machining milling design analysis.
Definition: DFMMachining_HighBossIssue.hxx:32
Describes inconsistent radius milled part floor fillet issue found during cnc machining milling desig...
Definition: DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue.hxx:32
Describes intersecting cavity hole issues found during cnc machining drilling design analysis.
Definition: DFMMachining_IntersectingCavityHoleIssue.hxx:31
Describes irregular outer diameter profile relief found during cnc machining turning design analysis.
Definition: DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue.hxx:33
Described the Narrow Pocket maximum to minimum sizes ratio issue found during cnc machining milling d...
Definition: DFMMachining_LargeDifferenceRegionsSizeInPocketIssue.hxx:34
Describes large milled part issue found during cnc machining milling design analysis.
Definition: DFMMachining_LargeMilledPartIssue.hxx:34
const DFMMachining_MilledPartSize & ExpectedMaxMilledPartSize() const
Definition: DFMMachining_LargeMilledPartIssue.cxx:73
Describes large turned part issue found during cnc machining turning design analysis.
Definition: DFMMachining_LargeTurnedPartIssue.hxx:34
const DFMMachining_TurnedPartSize & ExpectedMaxTurnedPartSize() const
Definition: DFMMachining_LargeTurnedPartIssue.cxx:72
Describes long-slender turned part issue found during cnc machining turning design analysis.
Definition: DFMMachining_LongSlenderTurnedPartIssue.hxx:31
Describes external edge fillet issue found during cnc machining milling design analysis.
Definition: DFMMachining_MilledPartExternalEdgeFilletIssue.hxx:32
Describes a base class for milling issues found during cnc machining milling design analysis.
Definition: DFMMachining_MillingIssue.hxx:35
Described the Narrow Pocket minimum size issue found during DFM analysis for Machining Milling operat...
Definition: DFMMachining_NarrowRegionInPocketIssue.hxx:32
Describes non perpendicular hole issues found during cnc machining drilling design analysis.
Definition: DFMMachining_NonPerpendicularHoleIssue.hxx:31
Describes non perpendicular milled part shape issue found during cnc machining milling design analysi...
Definition: DFMMachining_NonPerpendicularMilledPartShapeIssue.hxx:32
Describes non standard diameter hole issues found during cnc machining drilling design analysis.
Definition: DFMMachining_NonStandardDiameterHoleIssue.hxx:31
Describes non standard drill point angle blind hole issues found during cnc machining drilling design...
Definition: DFMMachining_NonStandardDrillPointAngleBlindHoleIssue.hxx:31
Describes non standard radius milled part floor fillet issue found during cnc machining milling desig...
Definition: DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue.hxx:32
Describes asymmetric axial slot issue found during cnc machining turning design analysis.
Definition: DFMMachining_NonSymmetricalAxialSlotIssue.hxx:33
Describes partial hole issues found during cnc machining drilling design analysis.
Definition: DFMMachining_PartialHoleIssue.hxx:31
Describes small depth blind bored hole relief found during cnc machining turning design analysis.
Definition: DFMMachining_SmallDepthBlindBoredHoleReliefIssue.hxx:33
Describes small diameter hole issues found during cnc machining drilling design analysis.
Definition: DFMMachining_SmallDiameterHoleIssue.hxx:31
Describes internal corner radius issues found during cnc machining milling design analysis.
Definition: DFMMachining_SmallRadiusMilledPartInternalCornerIssue.hxx:32
Describes internal corner radius issues found during cnc machining turning design analysis.
Definition: DFMMachining_SmallRadiusTurnedPartInternalCornerIssue.hxx:33
Describes square form keyway issue found during cnc machining turning design analysis.
Definition: DFMMachining_SquareEndKeywayIssue.hxx:33
Describes a base class for bend issues found during sheet metal design analysis.
Definition: DFMSheetMetal_BendIssue.hxx:37
Describes a base class for hole issues found during sheet metal design analysis.
Definition: DFMSheetMetal_HoleIssue.hxx:37
Describes inconsistent radius bend issues found during sheet metal design analysis.
Definition: DFMSheetMetal_InconsistentRadiusBendIssue.hxx:31
Describes irregular notch corner fillet radius issue found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.hxx:34
Describes irregular depth extruded hole issue found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularDepthExtrudedHoleIssue.hxx:33
Describes irregular open hem bend radius issue found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularRadiusOpenHemBendIssue.hxx:33
Describes irregular size bend relief issues found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularSizeBendReliefIssue.hxx:33
SheetMetal_BendRelief ExpectedMinBendRelief() const
Definition: DFMSheetMetal_IrregularSizeBendReliefIssue.cxx:124
SheetMetal_BendRelief FirstActualRelief() const
Returns the first relief of the bend if the bend relief issue was detected. Otherwise returns empty b...
Definition: DFMSheetMetal_IrregularSizeBendReliefIssue.cxx:133
Describes irregular size notch issues found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularSizeNotchIssue.hxx:34
Describes irregular size tab issues found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularSizeTabIssue.hxx:34
Describes large depth bead issue found during sheet metal design analysis.
Definition: DFMSheetMetal_LargeDepthBeadIssue.hxx:33
const DFMSheetMetal_SheetSize & NearestStandardSheetSize() const
Definition: DFMSheetMetal_NonStandardSheetSizeIssue.cxx:69
Describes small depth louver issue found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDepthLouverIssue.hxx:33
Describes small diameter hole issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDiameterHoleIssue.hxx:31
Describes small distance between bend and louver issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.hxx:34
Describes small distance between complex hole and bend issues found during sheet metal design analysi...
Definition: DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue.hxx:34
Describes small distance detween extruded hole and edge issues found during sheet metal design analys...
Definition: DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue.hxx:34
Describes small distance between extruded holes issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue.hxx:33
Describes a base class for small distance issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenFeaturesIssue.hxx:37
Describes small distance between hole and bend issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue.hxx:34
Describes small distance between hole and cutout issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue.hxx:34
Describes small distance detween hole and edge issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue.hxx:34
Describes small distance between hole and louver issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue.hxx:34
Describes small distance detween hole and notch issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue.hxx:34
Describes small distance detween holes issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHolesIssue.hxx:33
Describes small distance detween notch and bend issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue.hxx:34
Describes small distance between notches issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenNotchesIssue.hxx:33
Describes small distance between tabs issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenTabsIssue.hxx:33
Describes small length flange issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallLengthFlangeIssue.hxx:34
const MTKBase_CompositeFeature & Flange() const
Definition: DFMSheetMetal_SmallLengthFlangeIssue.cxx:112
Describes small length hem bend flange issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallLengthHemBendFlangeIssue.hxx:33
const MTKBase_CompositeFeature & Flange() const
Definition: DFMSheetMetal_SmallLengthHemBendFlangeIssue.cxx:122
Describes small radius bend issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallRadiusBendIssue.hxx:31
Describes a boss. In CNC Machining a boss is a protrusion or raised area on a workpiece that is creat...
Definition: MTKBase_Boss.hxx:27
Describeas a base class for composite features.
Definition: MTKBase_CompositeFeature.hxx:34
const MTKBase_FeatureList & FeatureList() const
Returns the feature references list.
Definition: MTKBase_CompositeFeature.cxx:94
Provides possibility to compare MTK based features depending on their type and parameters.
Definition: MTKBase_FeatureComparator.hxx:29
Describes a base class of MTK based features.
Definition: MTKBase_Feature.hxx:34
bool IsEmpty() const
Definition: MTKBase_FeatureList.hxx:53
Describes a feature with assigned shape.
Definition: MTKBase_ShapeFeature.hxx:34
Describes a machining countersink.
Definition: Machining_Countersink.hxx:33
Describes a face produced by a specified machining operation.
Definition: Machining_Face.hxx:38
Machining_FaceType Type() const
Definition: Machining_Face.cxx:216
Describes a machining hole of a specified type. Hole is a cylindrical feature that can be made by cut...
Definition: Machining_Hole.hxx:32
Machining_HoleType Type() const
Definition: Machining_Hole.cxx:142
Describes a machining pocket. A pocket is a feature obtained by milling the material inside an arbitr...
Definition: Machining_Pocket.hxx:32
Describes a face with radius produced by a specified machining operation. Cutting material from workp...
Definition: Machining_TurningFace.hxx:31
int ShapeId(const ModelData_Shape &theShape) const
Returns an Id of B-Rep shape.
Definition: ModelData_BRepRepresentation.cxx:1021
const ModelData_BodyList & Get() const
Returns an associated topological object.
Definition: ModelData_BRepRepresentation.cxx:626
Defines a 3D direction.
Definition: ModelData_Direction.hxx:180
Defines a 3D point.
Definition: ModelData_Point.hxx:295
Describes a sheet metal bead.
Definition: SheetMetal_Bead.hxx:31
Describes a bend in sheet metal.
Definition: SheetMetal_Bend.hxx:35
Describes a sheet metal bridge feature.
Definition: SheetMetal_Bridge.hxx:31
Describes a sheet metal complex hole feature.
Definition: SheetMetal_ComplexHole.hxx:31
Describes a sheet metal curved bend feature.
Definition: SheetMetal_CurvedBend.hxx:31
Describes a cutout in sheet metal.
Definition: SheetMetal_Cutout.hxx:31
Describes a sheet metal Hem bend feature.
Definition: SheetMetal_HemBend.hxx:32
Describes a circle hole drilled or punched in sheet metal.
Definition: SheetMetal_Hole.hxx:35
Describes a sheet metal louver feature.
Definition: SheetMetal_Louver.hxx:31
Describes a sheet metal notch.
Definition: SheetMetal_Notch.hxx:35
Describes a sheet metal straight notch.
Definition: SheetMetal_StraightNotch.hxx:31
Describes a sheet metal tab.
Definition: SheetMetal_Tab.hxx:31
Describes a sheet metal V-notch.
Definition: SheetMetal_VNotch.hxx:31
Machining_HoleType
Defines a hole type in machining.
Definition: Machining_HoleType.hxx:29
Machining_FaceType
Describes a face produced by a specified machining operation.
Definition: Machining_FaceType.hxx:29
SheetMetal_HemBendType
Defines a hem bend type in sheet metal.
Definition: SheetMetal_HemBendType.hxx:29
ModelData_ShapeType
Defines shape type.
Definition: ModelData_ShapeType.hxx:25

MTKConverter_Application.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#ifndef _MTKConverter_Application_HeaderFile
#define _MTKConverter_Application_HeaderFile
#include <cadex/ModelData_WriterParameters.hxx>
enum MTKConverter_ReturnCode
{
// General codes
MTKConverter_RC_OK = 0,
MTKConverter_RC_UnknownError = 1,
MTKConverter_RC_GeneralException = 2,
MTKConverter_RC_NoValidLicense = 3,
MTKConverter_RC_InvalidArgumentsNumber = 4,
MTKConverter_RC_InvalidArgument = 5,
// Import errors
MTKConverter_RC_UnsupportedVersion = 100,
MTKConverter_RC_UnexpectedFormat = 101,
MTKConverter_RC_UnsupportedFileVariant = 102,
MTKConverter_RC_ImportError = 103,
// Process errors
MTKConverter_RC_ProcessError = 200,
// Export errors
MTKConverter_RC_ExportError = 300,
};
class MTKConverter_Application
{
public:
MTKConverter_Application();
MTKConverter_ReturnCode Run (int argc, char *argv[]) const;
void PrintUsage() const;
cadex::ModelData_WriterParameters myCDXWEBWriterParameters;
};
#endif
Defines parameters used by the ModelData_Model::Save() function.
Definition: ModelData_WriterParameters.hxx:27

MTKConverter_Application.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// This file may be used under the terms and conditions of the License
// Agreement supplied with the software.
//
// This file is provided "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF DESIGN,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// ****************************************************************************
#include <cadex/BaseError_UnexpectedFormat.hxx>
#include <cadex/BaseError_UnsupportedFileVariant.hxx>
#include <cadex/BaseError_UnsupportedVersion.hxx>
#include <cadex/Base_Settings.hxx>
#include <cadex/ModelData_ModelReader.hxx>
#include <cadex/ModelData_SceneGraphElementUniqueVisitor.hxx>
#include <cadex/ModelPrs_BackgroundStyle.hxx>
#include <cadex/ModelPrs_OffscreenViewPort.hxx>
#include <cadex/ModelPrs_Scene.hxx>
#include <cadex/ModelPrs_SceneNode.hxx>
#include <cadex/ModelPrs_SceneNodeFactory.hxx>
#include <MTKConverter_Application.hxx>
#include <MTKConverter_MachiningProcessor.hxx>
#include <MTKConverter_Report.hxx>
#include <MTKConverter_SheetMetalProcessor.hxx>
#include <MTKConverter_WallThicknessProcessor.hxx>
#include <cstring>
#include <iostream>
#include <unordered_map>
using namespace cadex;
namespace {
enum MTKConverter_ProcessType
{
MTKConverter_PT_Undefined = -1,
MTKConverter_PT_WallThickness = 0,
MTKConverter_PT_MachiningMilling,
MTKConverter_PT_MachiningTurning,
MTKConverter_PT_SheetMetal
};
MTKConverter_ProcessType ProcessType (const Base_UTF16String& theProcessName)
{
static std::unordered_map<Base_UTF16String, MTKConverter_ProcessType, Base_UTF16StringHash> aProcessMap
{
{"wall_thickness" , MTKConverter_PT_WallThickness},
{"machining_milling", MTKConverter_PT_MachiningMilling},
{"machining_turning", MTKConverter_PT_MachiningTurning},
{"sheet_metal" , MTKConverter_PT_SheetMetal}
};
auto aRes = aProcessMap.find (theProcessName);
if (aRes != aProcessMap.end()) {
return aRes->second;
}
return MTKConverter_PT_Undefined;
}
MTKConverter_ReturnCode Import (const Base_UTF16String& theFilePath, ModelData_Model& theModel)
{
std::cout << "Importing " << theFilePath << "..." << std::flush;
if (!aReader.Read (theFilePath, theModel)) {
std::cerr << std::endl << "ERROR: Failed to import " << theFilePath << ". Exiting" << std::endl;
return MTKConverter_RC_ImportError;
}
return MTKConverter_RC_OK;
}
bool CreateOriginModelThumbnail (const Base_UTF16String& theFilePath, const ModelData_Model& theModel)
{
// Setup offscreen viewport with transparent background and perspective camera
aViewPort.Resize (800, 600);
aViewPort.SetCameraProjectionType (ModelPrs_CPT_Perspective);
aViewPort.SetCameraPositionType (ModelPrs_CMT_Default);
ModelData_Color aBackgroundColor (0x00000000);
ModelPrs_BackgroundStyle aStyle (aBackgroundColor);
aViewPort.SetBackgroundStyle (aStyle);
// Create scene and display all entities
auto aRootNode = aFactory.CreateGraph (theModel, ModelData_RM_Any);
aRootNode.SetDisplayMode (ModelPrs_DM_ShadedWithBoundaries);
aScene.AddRoot (aRootNode);
// Attach viewport to the scene.
if (!aViewPort.AttachToScene (aScene)) {
return false;
}
// Apply scene changes to viewport and wait until all async operations will be finished
aScene.Update();
aScene.Wait();
// Fit and center model on the image
aViewPort.FitAll();
// Save image
bool aRes = aViewPort.GrabToImage (theFilePath);
return aRes;
}
MTKConverter_ReturnCode Process (const Base_UTF16String& theProcess, ModelData_Model& theModel,
MTKConverter_Report& theReport, ModelData_Model& theProcessModel)
{
std::cout << "Processing " << theProcess << "..." << std::flush;
theModel.AssignUuids();
auto ApplyProcessorToModel = [&theModel, &theReport] (MTKConverter_PartProcessor& theProcessor) {
theModel.Accept (aVisitor);
for (const auto& i : theProcessor.myData) {
theReport.AddData (i);
}
};
auto aProcessType = ProcessType (theProcess);
switch (aProcessType) {
case MTKConverter_PT_WallThickness:
{
MTKConverter_WallThicknessProcessor aProcessor (800);
ApplyProcessorToModel (aProcessor);
break;
}
case MTKConverter_PT_MachiningMilling:
{
MTKConverter_MachiningProcessor aProcessor (Machining_OT_Milling);
ApplyProcessorToModel (aProcessor);
break;
}
case MTKConverter_PT_MachiningTurning:
{
MTKConverter_MachiningProcessor aProcessor (Machining_OT_LatheMilling);
ApplyProcessorToModel (aProcessor);
break;
}
case MTKConverter_PT_SheetMetal:
{
theProcessModel.SetName (theModel.Name() + "_unfolded");
MTKConverter_SheetMetalProcessor aProcessor (theProcessModel);
ApplyProcessorToModel (aProcessor);
break;
}
case MTKConverter_PT_Undefined:
default : return MTKConverter_RC_InvalidArgument;
}
return MTKConverter_RC_OK;
}
MTKConverter_ReturnCode Export (const Base_UTF16String& theFolderPath,
const ModelData_WriterParameters& theWriterParams,
const ModelData_Model& theModel,
const MTKConverter_Report& theReport,
const ModelData_Model& theProcessModel)
{
std::cout << "Exporting " << theFolderPath << "..." << std::flush;
Base_UTF16String aModelPath = theFolderPath + "/" + theModel.Name() + ".cdxweb" + "/scenegraph.cdxweb";
if (!theModel.Save (aModelPath, theWriterParams)) {
std::cerr << std::endl << "ERROR: Failed to export " << aModelPath << ". Exiting" << std::endl;
return MTKConverter_RC_ExportError;
}
Base_UTF16String aThumbnailPath = theFolderPath + "/thumbnail.png";
if (!CreateOriginModelThumbnail (aThumbnailPath, theModel)) {
std::cerr << std::endl << "ERROR: Failed to create thumbnail " << aThumbnailPath << ". Exiting" << std::endl;
return MTKConverter_RC_ExportError;
}
if (!theProcessModel.IsEmpty()) {
Base_UTF16String aProcessModelPath = theFolderPath + "/" + theProcessModel.Name() + ".cdxweb" + "/scenegraph.cdxweb";
if (!theProcessModel.Save (aProcessModelPath, theWriterParams)) {
std::cerr << std::endl << "ERROR: Failed to export " << aProcessModelPath << ". Exiting" << std::endl;
return MTKConverter_RC_ExportError;
}
}
Base_UTF16String aJsonPath = theFolderPath + "/process_data.json";
if (!theReport.WriteToJSON (aJsonPath)) {
std::cerr << std::endl << "ERROR: Failed to create JSON file " << aJsonPath << ". Exiting" << std::endl;
return MTKConverter_RC_ExportError;
}
return MTKConverter_RC_OK;
}
}
MTKConverter_Application::MTKConverter_Application()
{
//setup CDXWEB params
myCDXWEBWriterParameters.FileFormat() = ModelData_WriterParameters::FileFormatType::CDXWEB;
myCDXWEBWriterParameters.WriteBRepRepresentation() = true;
myCDXWEBWriterParameters.WritePolyRepresentation() = true;
myCDXWEBWriterParameters.PreferredLOD() = ModelData_RepresentationMask::ModelData_RM_Any;
myCDXWEBWriterParameters.WriteTextures() = true;
myCDXWEBWriterParameters.WritePMI() = true;
}
MTKConverter_ReturnCode MTKConverter_Application::Run (int argc, char *argv[]) const
{
if (argc == 1 || (
!strcmp (argv[1], "-?") || !strcmp (argv[1], "/?") ||
!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help"))) {
PrintUsage();
return MTKConverter_RC_OK;
}
if (argc < 6) {
std::cerr << "Invalid number of arguments. Please use \"-h\" or \"--help\" for usage information." << std::endl;
return MTKConverter_RC_InvalidArgumentsNumber;
}
//parse and execute command line
enum Mode { NeutralMode, ImportMode, ProcessMode, ExportMode };
ModelData_Model aProcessModel;
auto aMode = NeutralMode;
MTKConverter_Report aReport;
Base_Settings::Default()->SetValue (Base_Settings::UseExceptions, true);
auto aRes = MTKConverter_RC_OK;
for (int i = 1; (i < argc) && (aRes == MTKConverter_RC_OK); ++i) {
const Base_UTF16String anArgument = argv[i];
if (anArgument == "-i") {
aMode = ImportMode;
} else if (anArgument == "-p") {
aMode = ProcessMode;
} else if (anArgument == "-e") {
aMode = ExportMode;
} else {
try {
if (aMode == ImportMode) {
aRes = Import (anArgument, aModel);
} else if (aMode == ProcessMode) {
aRes = Process (anArgument, aModel, aReport, aProcessModel);
} else if (aMode == ExportMode) {
aRes = Export (anArgument, myCDXWEBWriterParameters, aModel, aReport, aProcessModel);
} else {
std::cerr << "ERROR!: Invalid argument " << anArgument << ". Exiting" << std::endl;
std::cerr << "Type " << argv[0] << " -h for help." << std::endl;
return MTKConverter_RC_InvalidArgument;
}
std::cout << "Done." << std::endl;
} catch (const BaseError_UnsupportedVersion& anE) {
std::cerr << "Failed.\nERROR: " << anE.What() << std::endl;
return MTKConverter_RC_UnsupportedVersion;
} catch (const BaseError_UnexpectedFormat& anE) {
std::cerr << "Failed.\nERROR: " << anE.What() << std::endl;
return MTKConverter_RC_UnexpectedFormat;
} catch (const BaseError_UnsupportedFileVariant& anE) {
std::cerr << "Failed.\nERROR: " << anE.What() << std::endl;
return MTKConverter_RC_UnsupportedFileVariant;
} catch (const Base_Exception& anE) {
std::cerr << "Failed.\nERROR: " << anE.What() << std::endl;
return MTKConverter_RC_GeneralException;
} catch (...) {
std::cerr << "Failed.\nERROR: Unhandled exception caught." << std::endl;
return MTKConverter_RC_GeneralException;
}
}
}
return aRes;
}
void MTKConverter_Application::PrintUsage() const
{
std::cout << "Usage:" << std::endl;
std::cout << "MTKConverter -i <import_file> -p <process> -e <export_folder>" << std::endl << std::endl;
std::cout << "Arguments:" << std::endl;
std::cout << " <import_file> - import file name" << std::endl;
std::cout << " <process> - manufacturing process or algorithm name" << std::endl;
std::cout << " <export_folder> - export folder name" << std::endl;
std::cout << "Example:" << std::endl;
std::cout << "MTKConverter -i C:\\models\\test.step -p machining_milling -e C:\\models\\test" << std::endl;
std::cout << std::endl << "Recognized processes:" << std::endl;
std::cout << " wall_thickness :\t Wall Thickness analysis" << std::endl;
std::cout << " machining_milling:\t CNC Machining Milling feature recognition and dfm analysis" << std::endl;
std::cout << " machining_turning:\t CNC Machining Lathe+Milling feature recognition and dfm analysis" << std::endl;
std::cout << " sheet_metal :\t Sheet Metal feature recognition, unfolding and dfm analysis" << std::endl;
}
Abstract base class for exceptions thrown from CAD Exchanger.
Definition: Base_Exception.hxx:34
const Base_UTF16String & What() const
Returns a message associated to the exception.
Definition: Base_Exception.cxx:61
Indicates that a file's format doesn't match the reader.
Definition: BaseError_UnexpectedFormat.hxx:29
Indicates that a file's variant doesn't match the variants, that reader supports.
Definition: BaseError_UnsupportedFileVariant.hxx:28
Indicates that a file of unsupported version was imported.
Definition: BaseError_UnsupportedVersion.hxx:27
Defines an RGBA color (with alpha channel).
Definition: ModelData_Color.hxx:34
bool Save(const Base_UTF16String &theFileName, const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus()) const
Definition: ModelData_Model.cxx:527
const Base_UTF16String & Name() const
Returns a model name.
Definition: ModelData_Model.cxx:358
void AssignUuids()
Definition: ModelData_Model.cxx:820
bool IsEmpty() const
Returns true if the model is empty.
Definition: ModelData_Model.cxx:812
void SetName(const Base_UTF16String &theName)
Sets a model name.
Definition: ModelData_Model.cxx:349
void Accept(ElementVisitor &theVisitor) const
Accepts a visitor.
Definition: ModelData_Model.cxx:882
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
bool Read(const Base_UTF16String &theFilePath, ModelData_Model &theModel)
Reads the file at the specified path into the specified model.
Definition: ModelData_ModelReader.cxx:182
Defines a visitor that visits each unique element only once.
Definition: ModelData_SceneGraphElementUniqueVisitor.hxx:33
Defines background style.
Definition: ModelPrs_BackgroundStyle.hxx:32
Defines a viewport without any visible window (frame).
Definition: ModelPrs_OffscreenViewPort.hxx:50
void SetBackgroundStyle(const ModelPrs_BackgroundStyle &theStyle)
Sets a background style.
Definition: ModelPrs_OffscreenViewPort.cxx:326
void SetCameraProjectionType(ModelPrs_CameraProjectionType theProjectionType)
Sets a camera projection type.
Definition: ModelPrs_OffscreenViewPort.cxx:378
void Resize(unsigned int theWidth, unsigned int theHeight)
Resizes ViewPort.
Definition: ModelPrs_OffscreenViewPort.cxx:264
bool AttachToScene(const ModelPrs_Scene &theScene)
Attaches to ModelPrs_Scene.
Definition: ModelPrs_OffscreenViewPort.cxx:257
void FitAll()
Fit content to ViewPort size.
Definition: ModelPrs_OffscreenViewPort.cxx:300
bool GrabToImage(const Base_UTF16String &thePath) const
Grab to image in specified thePath.
Definition: ModelPrs_OffscreenViewPort.cxx:285
void SetCameraPositionType(ModelPrs_CameraPositionType thePositionType)
Sets a camera position type.
Definition: ModelPrs_OffscreenViewPort.cxx:384
Provides CAD Exchanger visualization structure.
Definition: ModelPrs_Scene.hxx:39
void AddRoot(ModelPrs_SceneNode &theNode)
Adds a root scene node.
Definition: ModelPrs_Scene.cxx:138
void Wait()
Waiting until all changes are applied by Update method.
Definition: ModelPrs_Scene.cxx:207
void Update(const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus())
Applies changes of attached Scene Nodes.
Definition: ModelPrs_Scene.cxx:188
Creates a scene nodes and its children from input data model objects.
Definition: ModelPrs_SceneNodeFactory.hxx:53
ModelPrs_SceneNode CreateGraph(const ModelData_Model &theModel, ModelData_RepresentationMask theRepresentationMask)
Creates scene graph using ModelData_Model.
Definition: ModelPrs_SceneNodeFactory.cxx:735
void SetDisplayMode(ModelPrs_DisplayMode theMode)
Sets theMode as display mode.
Definition: ModelPrs_SceneNode.cxx:860

main.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#include <cadex/LicenseManager_Activate.h>
#include <MTKConverter_Application.hxx>
#include <iostream>
#include "../../cadex_license.cxx"
#include "../../mtk_license.cxx"
using namespace cadex;
using namespace std;
int main (int argc, char* argv[])
{
auto aKey = LicenseKey::Value();
auto anMTKKey = MTKLicenseKey::Value();
// Activate the license (aKey must be defined in cadex_license.cxx
// and anMTKKey must be defined in mtk_license.cxx)
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate CAD Exchanger license." << endl;
return 1;
}
if (!CADExLicense_Activate (anMTKKey)) {
cerr << "Failed to activate Manufacturing Toolkit license." << endl;
return 1;
}
MTKConverter_Application anApp;
return anApp.Run (argc, argv);
}