mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Compare commits
2 Commits
CR506
...
CR0-glb-st
Author | SHA1 | Date | |
---|---|---|---|
|
d979d19715 | ||
|
f2f107d6f7 |
@@ -268,7 +268,7 @@ function (EXTRACT_PACKAGE_FILES RELATIVE_PATH OCCT_PACKAGE RESULT_FILES RESULT_I
|
||||
set (OCCT_PACKAGE_FILES "${OCCT_${OCCT_PACKAGE}_FILES}")
|
||||
|
||||
# collect and search for the files in the package directory or patched one
|
||||
# FILE only contains filename that must to be inside package or patched directory
|
||||
# FILE contains inly filename that must to be inside package or patched directory
|
||||
set (FILE_PATH_LIST)
|
||||
|
||||
foreach (OCCT_FILE ${OCCT_PACKAGE_FILES})
|
||||
|
@@ -71,12 +71,7 @@ if (WIN32)
|
||||
|
||||
# Get installed configuration of tbb
|
||||
get_target_property (TARGET_TBB_IMPORT_CONFS TBB::tbb IMPORTED_CONFIGURATIONS)
|
||||
# Prioritize RELEASE configuration if available
|
||||
if (";${TARGET_TBB_IMPORT_CONFS};" MATCHES ";RELEASE;")
|
||||
set (CHOSEN_IMPORT_CONF "RELEASE")
|
||||
else()
|
||||
list (GET TARGET_TBB_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
|
||||
endif()
|
||||
list (GET TARGET_TBB_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
|
||||
|
||||
separate_arguments (CSF_TBB)
|
||||
foreach (LIB IN LISTS CSF_TBB)
|
||||
@@ -209,12 +204,7 @@ else ()
|
||||
|
||||
# Get installed configuration of tbb
|
||||
get_target_property (TARGET_TBB_IMPORT_CONFS TBB::tbb IMPORTED_CONFIGURATIONS)
|
||||
# Prioritize RELEASE configuration if available
|
||||
if (";${TARGET_TBB_IMPORT_CONFS};" MATCHES ";RELEASE;")
|
||||
set (CHOSEN_IMPORT_CONF "RELEASE")
|
||||
else()
|
||||
list (GET TARGET_TBB_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
|
||||
endif()
|
||||
list (GET TARGET_TBB_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
|
||||
|
||||
separate_arguments (CSF_TBB)
|
||||
foreach (LIB IN LISTS CSF_TBB)
|
||||
|
@@ -19,4 +19,4 @@
|
||||
set (OCC_VERSION_MAJOR 8 )
|
||||
set (OCC_VERSION_MINOR 0 )
|
||||
set (OCC_VERSION_MAINTENANCE 0 )
|
||||
set (OCC_VERSION_DEVELOPMENT "rc1" )
|
||||
set (OCC_VERSION_DEVELOPMENT "dev" )
|
||||
|
@@ -100,8 +100,6 @@ bool DEGLTF_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe
|
||||
theResource->BooleanVal("read.print.debug.message",
|
||||
InternalParameters.ReadPrintDebugMessages,
|
||||
aScope);
|
||||
InternalParameters.ReadApplyScale =
|
||||
theResource->BooleanVal("read.apply.scale", InternalParameters.ReadApplyScale, aScope);
|
||||
|
||||
InternalParameters.WriteComment =
|
||||
theResource->StringVal("write.comment", InternalParameters.WriteComment, aScope);
|
||||
@@ -262,13 +260,6 @@ TCollection_AsciiString DEGLTF_ConfigurationNode::Save() const
|
||||
aScope + "read.print.debug.message :\t " + InternalParameters.ReadPrintDebugMessages + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult +=
|
||||
"!Flag to apply non-uniform transformation directly to the triangulation (modify nodes)\n";
|
||||
aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
|
||||
aResult += aScope + "read.apply.scale :\t " + InternalParameters.ReadApplyScale + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Write parameters:\n";
|
||||
aResult += "!\n";
|
||||
|
@@ -101,7 +101,6 @@ public:
|
||||
bool ReadSkipLateDataLoading = false; //!< Flag to skip triangulation loading
|
||||
bool ReadKeepLateData = true;//!< Flag to keep information about deferred storage to load/unload triangulation later
|
||||
bool ReadPrintDebugMessages = false; //!< Flag to print additional debug information
|
||||
bool ReadApplyScale = true; //!< Flag to apply non-uniform scale factor to the triangulations (modify nodes coordinates)
|
||||
// Writing
|
||||
TCollection_AsciiString WriteComment; //!< Export special comment
|
||||
TCollection_AsciiString WriteAuthor; //!< Author of exported file name
|
||||
|
@@ -41,7 +41,6 @@ static void SetReaderParameters(RWGltf_CafReader& theReade
|
||||
theReader.SetToSkipLateDataLoading(theNode->InternalParameters.ReadSkipLateDataLoading);
|
||||
theReader.SetToKeepLateData(theNode->InternalParameters.ReadKeepLateData);
|
||||
theReader.SetToPrintDebugMessages(theNode->InternalParameters.ReadPrintDebugMessages);
|
||||
theReader.SetToApplyScale(theNode->InternalParameters.ReadApplyScale);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@@ -26,11 +26,6 @@
|
||||
#include <OSD_FileSystem.hxx>
|
||||
#include <OSD_ThreadPool.hxx>
|
||||
#include <RWGltf_GltfLatePrimitiveArray.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeMapTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWGltf_CafReader, RWMesh_CafReader)
|
||||
|
||||
@@ -175,8 +170,7 @@ RWGltf_CafReader::RWGltf_CafReader()
|
||||
myIsDoublePrecision(false),
|
||||
myToSkipLateDataLoading(false),
|
||||
myToKeepLateData(true),
|
||||
myToPrintDebugMessages(false),
|
||||
myToApplyScale(true)
|
||||
myToPrintDebugMessages(false)
|
||||
{
|
||||
myCoordSysConverter.SetInputLengthUnit(1.0); // glTF defines model in meters
|
||||
myCoordSysConverter.SetInputCoordinateSystem(RWMesh_CoordinateSystem_glTF);
|
||||
@@ -305,9 +299,6 @@ Standard_Boolean RWGltf_CafReader::performMesh(std::istream& th
|
||||
{
|
||||
aDoc.SetBinaryFormat(aBinBodyOffset, aBinBodyLen);
|
||||
}
|
||||
myShapeScaleMap = new NCollection_DataMap<TopoDS_Shape, gp_XYZ, TopTools_ShapeMapHasher>();
|
||||
aDoc.SetToApplyScale(myToApplyScale);
|
||||
aDoc.SetScaleMap(*myShapeScaleMap);
|
||||
|
||||
#ifdef HAVE_RAPIDJSON
|
||||
rapidjson::ParseResult aRes;
|
||||
@@ -427,263 +418,3 @@ void RWGltf_CafReader::updateLateDataReader(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void RWGltf_CafReader::fillDocument()
|
||||
{
|
||||
if (!myToFillDoc || myXdeDoc.IsNull() || myRootShapes.IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
// set units
|
||||
Standard_Real aLengthUnit = 1.;
|
||||
if (!XCAFDoc_DocumentTool::GetLengthUnit(myXdeDoc, aLengthUnit))
|
||||
{
|
||||
XCAFDoc_DocumentTool::SetLengthUnit(myXdeDoc, SystemLengthUnit());
|
||||
}
|
||||
else if (aLengthUnit != SystemLengthUnit())
|
||||
{
|
||||
Message::SendWarning("Warning: Length unit of document not equal to the system length unit");
|
||||
}
|
||||
|
||||
const Standard_Boolean wasAutoNaming = XCAFDoc_ShapeTool::AutoNaming();
|
||||
XCAFDoc_ShapeTool::SetAutoNaming(Standard_False);
|
||||
const TCollection_AsciiString aRootName; // = generateRootName (theFile);
|
||||
CafDocumentTools aTools;
|
||||
aTools.ShapeTool = XCAFDoc_DocumentTool::ShapeTool(myXdeDoc->Main());
|
||||
aTools.ColorTool = XCAFDoc_DocumentTool::ColorTool(myXdeDoc->Main());
|
||||
aTools.VisMaterialTool = XCAFDoc_DocumentTool::VisMaterialTool(myXdeDoc->Main());
|
||||
for (TopTools_SequenceOfShape::Iterator aRootIter(myRootShapes); aRootIter.More();
|
||||
aRootIter.Next())
|
||||
{
|
||||
addShapeIntoDoc(aTools, aRootIter.Value(), TDF_Label(), aRootName);
|
||||
}
|
||||
XCAFDoc_DocumentTool::ShapeTool(myXdeDoc->Main())->UpdateAssemblies();
|
||||
XCAFDoc_ShapeTool::SetAutoNaming(wasAutoNaming);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean RWGltf_CafReader::addShapeIntoDoc(CafDocumentTools& theTools,
|
||||
const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theLabel,
|
||||
const TCollection_AsciiString& theParentName,
|
||||
const Standard_Boolean theHasScale,
|
||||
const gp_XYZ& theScale)
|
||||
{
|
||||
if (theShape.IsNull() || myXdeDoc.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
const TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
|
||||
TopoDS_Shape aShapeToAdd = theShape;
|
||||
const TopoDS_Shape aShapeNoLoc = theShape.Located(TopLoc_Location());
|
||||
Standard_Boolean toMakeAssembly = Standard_False;
|
||||
bool isShapeScaled = myShapeScaleMap->IsBound(theShape);
|
||||
gp_XYZ aCurScale;
|
||||
|
||||
if (theHasScale)
|
||||
{
|
||||
// update translation part
|
||||
gp_Trsf aTrsf = theShape.Location().Transformation();
|
||||
gp_XYZ aTranslation = aTrsf.TranslationPart();
|
||||
aTranslation.SetX(aTranslation.X() * theScale.X());
|
||||
aTranslation.SetY(aTranslation.Y() * theScale.Y());
|
||||
aTranslation.SetZ(aTranslation.Z() * theScale.Z());
|
||||
aTrsf.SetTranslationPart(aTranslation);
|
||||
aShapeToAdd.Location(TopLoc_Location(aTrsf));
|
||||
}
|
||||
|
||||
if (isShapeScaled && aShapeType == TopAbs_FACE)
|
||||
{
|
||||
// Scale triangulation
|
||||
aCurScale = myShapeScaleMap->Find(theShape);
|
||||
TopLoc_Location aLoc;
|
||||
TopoDS_Face aFace = TopoDS::Face(aShapeToAdd);
|
||||
myShapeScaleMap->UnBind(theShape);
|
||||
const Handle(Poly_Triangulation)& aPolyTri = BRep_Tool::Triangulation(aFace, aLoc);
|
||||
if (!aPolyTri.IsNull())
|
||||
{
|
||||
for (int aNodeIdx = 1; aNodeIdx <= aPolyTri->NbNodes(); ++aNodeIdx)
|
||||
{
|
||||
gp_Pnt aNode = aPolyTri->Node(aNodeIdx);
|
||||
aNode.SetX(aNode.X() * aCurScale.X());
|
||||
aNode.SetY(aNode.Y() * aCurScale.Y());
|
||||
aNode.SetZ(aNode.Z() * aCurScale.Z());
|
||||
aPolyTri->SetNode(aNodeIdx, aNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (theShape.ShapeType() == TopAbs_COMPOUND)
|
||||
{
|
||||
RWMesh_NodeAttributes aSubFaceAttribs;
|
||||
for (TopoDS_Iterator aSubShapeIter(theShape, Standard_True, Standard_False);
|
||||
!toMakeAssembly && aSubShapeIter.More();
|
||||
aSubShapeIter.Next())
|
||||
{
|
||||
if (aSubShapeIter.Value().ShapeType() != TopAbs_FACE)
|
||||
{
|
||||
toMakeAssembly = Standard_True;
|
||||
break;
|
||||
}
|
||||
|
||||
const TopoDS_Face& aFace = TopoDS::Face(aSubShapeIter.Value());
|
||||
toMakeAssembly =
|
||||
toMakeAssembly
|
||||
|| (myAttribMap.Find(aFace, aSubFaceAttribs) && !aSubFaceAttribs.Name.IsEmpty());
|
||||
}
|
||||
|
||||
if (toMakeAssembly)
|
||||
{
|
||||
// create an empty Compound to add as assembly, so that we can add children one-by-one via
|
||||
// AddComponent()
|
||||
TopoDS_Compound aCompound;
|
||||
BRep_Builder aBuilder;
|
||||
aBuilder.MakeCompound(aCompound);
|
||||
aCompound.Location(theShape.Location(), Standard_False);
|
||||
aShapeToAdd = aCompound;
|
||||
}
|
||||
}
|
||||
|
||||
TDF_Label aNewLabel, anOldLabel;
|
||||
if (theLabel.IsNull())
|
||||
{
|
||||
// add new shape
|
||||
aNewLabel = theTools.ShapeTool->AddShape(aShapeToAdd, toMakeAssembly);
|
||||
}
|
||||
else if (theTools.ShapeTool->IsAssembly(theLabel))
|
||||
{
|
||||
// add shape as component
|
||||
if (theTools.ComponentMap.Find(aShapeNoLoc, anOldLabel))
|
||||
{
|
||||
aNewLabel = theTools.ShapeTool->AddComponent(theLabel, anOldLabel, theShape.Location());
|
||||
}
|
||||
else
|
||||
{
|
||||
aNewLabel = theTools.ShapeTool->AddComponent(theLabel, aShapeToAdd, toMakeAssembly);
|
||||
|
||||
TDF_Label aRefLabel = aNewLabel;
|
||||
theTools.ShapeTool->GetReferredShape(aNewLabel, aRefLabel);
|
||||
if (!aRefLabel.IsNull())
|
||||
{
|
||||
theTools.ComponentMap.Bind(aShapeNoLoc, aRefLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// add shape as sub-shape
|
||||
aNewLabel = theTools.ShapeTool->AddSubShape(theLabel, theShape);
|
||||
if (!aNewLabel.IsNull())
|
||||
{
|
||||
Handle(XCAFDoc_ShapeMapTool) aShapeMapTool = XCAFDoc_ShapeMapTool::Set(aNewLabel);
|
||||
aShapeMapTool->SetShape(theShape);
|
||||
}
|
||||
}
|
||||
if (aNewLabel.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (toMakeAssembly)
|
||||
{
|
||||
TDF_Label aRefLabel;
|
||||
theTools.ShapeTool->GetReferredShape(aNewLabel, aRefLabel);
|
||||
if (!aRefLabel.IsNull())
|
||||
{
|
||||
theTools.OriginalShapeMap.Bind(theShape, aRefLabel);
|
||||
}
|
||||
}
|
||||
|
||||
// if new label is a reference get referred shape
|
||||
TDF_Label aNewRefLabel = aNewLabel;
|
||||
theTools.ShapeTool->GetReferredShape(aNewLabel, aNewRefLabel);
|
||||
|
||||
RWMesh_NodeAttributes aRefShapeAttribs;
|
||||
myAttribMap.Find(aShapeNoLoc, aRefShapeAttribs);
|
||||
|
||||
bool hasProductName = false;
|
||||
if (aNewLabel != aNewRefLabel)
|
||||
{
|
||||
// put attributes to the Instance (overrides Product attributes)
|
||||
RWMesh_NodeAttributes aShapeAttribs;
|
||||
if (!theShape.Location().IsIdentity() && myAttribMap.Find(theShape, aShapeAttribs))
|
||||
{
|
||||
if (!aShapeAttribs.Style.IsEqual(aRefShapeAttribs.Style))
|
||||
{
|
||||
setShapeStyle(theTools, aNewLabel, aShapeAttribs.Style);
|
||||
}
|
||||
if (aShapeAttribs.NamedData != aRefShapeAttribs.NamedData)
|
||||
{
|
||||
setShapeNamedData(theTools, aNewLabel, aShapeAttribs.NamedData);
|
||||
}
|
||||
setShapeName(aNewLabel, aShapeType, aShapeAttribs.Name, theLabel, theParentName);
|
||||
if (aRefShapeAttribs.Name.IsEmpty() && !aShapeAttribs.Name.IsEmpty())
|
||||
{
|
||||
// it is not nice having unnamed Product, so copy name from first Instance (probably the
|
||||
// only one)
|
||||
hasProductName = true;
|
||||
setShapeName(aNewRefLabel, aShapeType, aShapeAttribs.Name, theLabel, theParentName);
|
||||
}
|
||||
else if (aShapeAttribs.Name.IsEmpty() && !aRefShapeAttribs.Name.IsEmpty())
|
||||
{
|
||||
// copy name from Product
|
||||
setShapeName(aNewLabel, aShapeType, aRefShapeAttribs.Name, theLabel, theParentName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// copy name from Product
|
||||
setShapeName(aNewLabel, aShapeType, aRefShapeAttribs.Name, theLabel, theParentName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!anOldLabel.IsNull())
|
||||
{
|
||||
// already defined in the document
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// put attributes to the Product (shared across Instances)
|
||||
if (!hasProductName)
|
||||
{
|
||||
setShapeName(aNewRefLabel, aShapeType, aRefShapeAttribs.Name, theLabel, theParentName);
|
||||
}
|
||||
setShapeStyle(theTools, aNewRefLabel, aRefShapeAttribs.Style);
|
||||
setShapeNamedData(theTools, aNewRefLabel, aRefShapeAttribs.NamedData);
|
||||
|
||||
if (theTools.ShapeTool->IsAssembly(aNewRefLabel))
|
||||
{
|
||||
bool aHasScale = theHasScale | isShapeScaled;
|
||||
gp_XYZ aScale = theScale;
|
||||
if (isShapeScaled)
|
||||
{
|
||||
aScale.SetX(aCurScale.X() * theScale.X());
|
||||
aScale.SetY(aCurScale.Y() * theScale.Y());
|
||||
aScale.SetZ(aCurScale.Z() * theScale.Z());
|
||||
}
|
||||
// store sub-shapes (iterator is set to not inherit Location of parent object)
|
||||
TCollection_AsciiString aDummyName;
|
||||
for (TopoDS_Iterator aSubShapeIter(theShape, Standard_True, Standard_False);
|
||||
aSubShapeIter.More();
|
||||
aSubShapeIter.Next())
|
||||
{
|
||||
addShapeIntoDoc(theTools, aSubShapeIter.Value(), aNewRefLabel, aDummyName, aHasScale, aScale);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// store a plain list of sub-shapes in case if they have custom attributes (usually per-face
|
||||
// color)
|
||||
for (TopoDS_Iterator aSubShapeIter(theShape, Standard_True, Standard_False);
|
||||
aSubShapeIter.More();
|
||||
aSubShapeIter.Next())
|
||||
{
|
||||
addSubShapeIntoDoc(theTools, aSubShapeIter.Value(), aNewRefLabel);
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -45,10 +45,6 @@ public:
|
||||
//! main (default) scene will be loaded.
|
||||
bool ToLoadAllScenes() const { return myToLoadAllScenes; }
|
||||
|
||||
//! Return TRUE if non-uniform scaling should be applied directly to the triangulation.
|
||||
//! FALSE if the average scale should be applied to the transformation matrix.
|
||||
bool ToApplyScale() const { return myToApplyScale; }
|
||||
|
||||
//! Set flag to flag to load all scenes in the document, FALSE by default which means only main
|
||||
//! (default) scene will be loaded.
|
||||
void SetLoadAllScenes(bool theToLoadAll) { myToLoadAllScenes = theToLoadAll; }
|
||||
@@ -71,10 +67,6 @@ public:
|
||||
//! Sets flag to skip data loading.
|
||||
void SetToSkipLateDataLoading(bool theToSkip) { myToSkipLateDataLoading = theToSkip; }
|
||||
|
||||
//! Set flag to apply non-uniform scaling directly to the triangulation (modify nodes).
|
||||
//! TRUE by default. In case of FALSE the average scale is applied to the transformation matrix.
|
||||
void SetToApplyScale(bool theToApplyScale) { myToApplyScale = theToApplyScale; }
|
||||
|
||||
//! Returns TRUE if data should be loaded into itself without its transferring to new structure.
|
||||
//! It allows to keep information about deferred storage to load/unload this data later.
|
||||
//! TRUE by default.
|
||||
@@ -100,17 +92,6 @@ protected:
|
||||
const Standard_Boolean theToProbe)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Fill document with new root shapes.
|
||||
Standard_EXPORT virtual void fillDocument() Standard_OVERRIDE;
|
||||
|
||||
//! Append new shape into the document (recursively).
|
||||
Standard_EXPORT Standard_Boolean addShapeIntoDoc(CafDocumentTools& theTools,
|
||||
const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theLabel,
|
||||
const TCollection_AsciiString& theParentName,
|
||||
const Standard_Boolean theHasScale = false,
|
||||
const gp_XYZ& theScale = gp_XYZ(0., 0., 0.));
|
||||
|
||||
//! Create primitive array reader context.
|
||||
//! Can be overridden by sub-class to read triangulation into application-specific data structures
|
||||
//! instead of Poly_Triangulation. Default implementation creates RWGltf_TriangulationReader.
|
||||
@@ -142,9 +123,6 @@ protected:
|
||||
Standard_Boolean myToKeepLateData; //!< flag to keep information about deferred storage to load/unload triangulation later
|
||||
// clang-format on
|
||||
Standard_Boolean myToPrintDebugMessages; //!< flag to print additional debug information
|
||||
Standard_Boolean myToApplyScale; //!< flag to apply non-uniform scaling
|
||||
NCollection_DataMap<TopoDS_Shape, gp_XYZ, TopTools_ShapeMapHasher>*
|
||||
myShapeScaleMap; //!< map of shapes with non-uniform scalings
|
||||
};
|
||||
|
||||
#endif // _RWGltf_CafReader_HeaderFile
|
||||
|
@@ -15,7 +15,6 @@
|
||||
#include "RWGltf_GltfJsonParser.hxx"
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <FSD_Base64.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
@@ -505,11 +504,8 @@ bool RWGltf_GltfJsonParser::parseTransformationComponents(
|
||||
const RWGltf_JsonValue* theRotationVal,
|
||||
const RWGltf_JsonValue* theScaleVal,
|
||||
const RWGltf_JsonValue* theTranslationVal,
|
||||
TopLoc_Location& theResult,
|
||||
bool& theHasScale,
|
||||
gp_XYZ& theScale) const
|
||||
TopLoc_Location& theResult) const
|
||||
{
|
||||
theHasScale = false;
|
||||
gp_Trsf aTrsf;
|
||||
if (theRotationVal != NULL)
|
||||
{
|
||||
@@ -588,16 +584,13 @@ bool RWGltf_GltfJsonParser::parseTransformationComponents(
|
||||
|| Abs(aScaleVec.y() - aScaleVec.z()) > Precision::Confusion()
|
||||
|| Abs(aScaleVec.x() - aScaleVec.z()) > Precision::Confusion())
|
||||
{
|
||||
Graphic3d_Mat4d aScaleMat;
|
||||
aScaleMat.SetDiagonal(aScaleVec);
|
||||
|
||||
Graphic3d_Mat4d aMat4;
|
||||
aTrsf.GetMat4(aMat4);
|
||||
|
||||
if (!myToApplyScale)
|
||||
{
|
||||
Graphic3d_Mat4d aScaleMat;
|
||||
aScaleMat.SetDiagonal(aScaleVec);
|
||||
aMat4 = aMat4 * aScaleMat;
|
||||
}
|
||||
|
||||
aMat4 = aMat4 * aScaleMat;
|
||||
aTrsf = gp_Trsf();
|
||||
aTrsf.SetValues(aMat4.GetValue(0, 0),
|
||||
aMat4.GetValue(0, 1),
|
||||
@@ -612,18 +605,9 @@ bool RWGltf_GltfJsonParser::parseTransformationComponents(
|
||||
aMat4.GetValue(2, 2),
|
||||
aMat4.GetValue(2, 3));
|
||||
|
||||
TCollection_AsciiString aWarnMessage = TCollection_AsciiString("glTF reader, scene node '")
|
||||
+ theSceneNodeId + "' defines unsupported scaling "
|
||||
+ aScaleVec.x() + " " + aScaleVec.y() + " "
|
||||
+ aScaleVec.z();
|
||||
if (myToApplyScale)
|
||||
{
|
||||
aWarnMessage += TCollection_AsciiString(". It was applied to the triangulation directly");
|
||||
theHasScale = true;
|
||||
theScale = gp_XYZ(aScaleVec.x(), aScaleVec.y(), aScaleVec.z());
|
||||
}
|
||||
|
||||
Message::SendWarning(aWarnMessage);
|
||||
Message::SendWarning(TCollection_AsciiString("glTF reader, scene node '") + theSceneNodeId
|
||||
+ "' defines unsupported scaling " + aScaleVec.x() + " " + aScaleVec.y()
|
||||
+ " " + aScaleVec.z());
|
||||
}
|
||||
else if (Abs(aScaleVec.x() - 1.0) > Precision::Confusion())
|
||||
{
|
||||
@@ -654,7 +638,6 @@ RWGltf_GltfJsonParser::RWGltf_GltfJsonParser(TopTools_SequenceOfShape& theRootSh
|
||||
: myRootShapes(&theRootShapes),
|
||||
myAttribMap(NULL),
|
||||
myExternalFiles(NULL),
|
||||
myShapeScaleMap(NULL),
|
||||
myMetadata(NULL),
|
||||
myBinBodyOffset(0),
|
||||
myBinBodyLen(0),
|
||||
@@ -664,8 +647,7 @@ RWGltf_GltfJsonParser::RWGltf_GltfJsonParser(TopTools_SequenceOfShape& theRootSh
|
||||
myToLoadAllScenes(false),
|
||||
myUseMeshNameAsFallback(true),
|
||||
myToProbeHeader(false),
|
||||
myToReadAssetExtras(true),
|
||||
myToApplyScale(true)
|
||||
myToReadAssetExtras(true)
|
||||
{
|
||||
myCSTrsf.SetInputLengthUnit(1.0); // meters
|
||||
myCSTrsf.SetInputCoordinateSystem(RWMesh_CoordinateSystem_glTF);
|
||||
@@ -1585,8 +1567,6 @@ bool RWGltf_GltfJsonParser::gltfParseSceneNode(TopoDS_Shape& th
|
||||
const RWGltf_JsonValue* anExtrasVal = findObjectMember(theSceneNode, "extras");
|
||||
|
||||
TopLoc_Location aNodeLoc;
|
||||
bool aHasScale = false;
|
||||
gp_XYZ aScale;
|
||||
const bool aHasTransformComponents =
|
||||
aTrsfRotVal != NULL || aTrsfScaleVal != NULL || aTrsfTransVal != NULL;
|
||||
const bool aHasTransformMatrix = aTrsfMatVal != NULL;
|
||||
@@ -1608,9 +1588,7 @@ bool RWGltf_GltfJsonParser::gltfParseSceneNode(TopoDS_Shape& th
|
||||
aTrsfRotVal,
|
||||
aTrsfScaleVal,
|
||||
aTrsfTransVal,
|
||||
aNodeLoc,
|
||||
aHasScale,
|
||||
aScale))
|
||||
aNodeLoc))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1627,7 +1605,7 @@ bool RWGltf_GltfJsonParser::gltfParseSceneNode(TopoDS_Shape& th
|
||||
if (aChildren != NULL && !gltfParseSceneNodes(aChildShapes, *aChildren, theProgress))
|
||||
{
|
||||
theNodeShape = aNodeShape;
|
||||
bindNodeShape(theNodeShape, aNodeLoc, aHasScale, aScale, theSceneNodeId, aName, anExtras);
|
||||
bindNodeShape(theNodeShape, aNodeLoc, theSceneNodeId, aName, anExtras);
|
||||
return false;
|
||||
}
|
||||
for (TopTools_SequenceOfShape::Iterator aChildShapeIter(aChildShapes); aChildShapeIter.More();
|
||||
@@ -1649,7 +1627,7 @@ bool RWGltf_GltfJsonParser::gltfParseSceneNode(TopoDS_Shape& th
|
||||
if (aMesh == NULL)
|
||||
{
|
||||
theNodeShape = aNodeShape;
|
||||
bindNodeShape(theNodeShape, aNodeLoc, aHasScale, aScale, theSceneNodeId, aName, anExtras);
|
||||
bindNodeShape(theNodeShape, aNodeLoc, theSceneNodeId, aName, anExtras);
|
||||
reportGltfError("Scene node '" + theSceneNodeId + "' refers to non-existing mesh.");
|
||||
return false;
|
||||
}
|
||||
@@ -1658,7 +1636,7 @@ bool RWGltf_GltfJsonParser::gltfParseSceneNode(TopoDS_Shape& th
|
||||
if (!gltfParseMesh(aMeshShape, getKeyString(*aMeshIter), *aMesh))
|
||||
{
|
||||
theNodeShape = aNodeShape;
|
||||
bindNodeShape(theNodeShape, aNodeLoc, aHasScale, aScale, theSceneNodeId, aName, anExtras);
|
||||
bindNodeShape(theNodeShape, aNodeLoc, theSceneNodeId, aName, anExtras);
|
||||
return false;
|
||||
}
|
||||
if (!aMeshShape.IsNull())
|
||||
@@ -1676,7 +1654,7 @@ bool RWGltf_GltfJsonParser::gltfParseSceneNode(TopoDS_Shape& th
|
||||
if (aMesh == NULL)
|
||||
{
|
||||
theNodeShape = aNodeShape;
|
||||
bindNodeShape(theNodeShape, aNodeLoc, aHasScale, aScale, theSceneNodeId, aName, anExtras);
|
||||
bindNodeShape(theNodeShape, aNodeLoc, theSceneNodeId, aName, anExtras);
|
||||
reportGltfError("Scene node '" + theSceneNodeId + "' refers to non-existing mesh.");
|
||||
return false;
|
||||
}
|
||||
@@ -1685,15 +1663,13 @@ bool RWGltf_GltfJsonParser::gltfParseSceneNode(TopoDS_Shape& th
|
||||
if (!gltfParseMesh(aMeshShape, getKeyString(*aMesh_2), *aMesh))
|
||||
{
|
||||
theNodeShape = aNodeShape;
|
||||
bindNodeShape(theNodeShape, aNodeLoc, aHasScale, aScale, theSceneNodeId, aName, anExtras);
|
||||
bindNodeShape(theNodeShape, aNodeLoc, theSceneNodeId, aName, anExtras);
|
||||
return false;
|
||||
}
|
||||
if (!aMeshShape.IsNull())
|
||||
{
|
||||
aBuilder.Add(aNodeShape, aMeshShape);
|
||||
++aNbSubShapes;
|
||||
if (aHasScale)
|
||||
myShapeScaleMap->Bind(aMeshShape, aScale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1705,7 +1681,7 @@ bool RWGltf_GltfJsonParser::gltfParseSceneNode(TopoDS_Shape& th
|
||||
{
|
||||
theNodeShape = aNodeShape;
|
||||
}
|
||||
bindNodeShape(theNodeShape, aNodeLoc, aHasScale, aScale, theSceneNodeId, aName, anExtras);
|
||||
bindNodeShape(theNodeShape, aNodeLoc, theSceneNodeId, aName, anExtras);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2361,11 +2337,10 @@ bool RWGltf_GltfJsonParser::gltfParseBuffer(
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void RWGltf_GltfJsonParser::bindNamedShape(TopoDS_Shape& theShape,
|
||||
ShapeMapGroup theGroup,
|
||||
const TopLoc_Location& theLoc,
|
||||
const bool theHasScale,
|
||||
const gp_XYZ& theScale,
|
||||
const TCollection_AsciiString& theId,
|
||||
const RWGltf_JsonValue* theUserName,
|
||||
const Handle(TDataStd_NamedData)& theExtras)
|
||||
@@ -2375,19 +2350,6 @@ void RWGltf_GltfJsonParser::bindNamedShape(TopoDS_Shape& the
|
||||
return;
|
||||
}
|
||||
|
||||
if (theHasScale && myShapeScaleMap->IsBound(theShape))
|
||||
{
|
||||
// Check scaling values
|
||||
gp_XYZ aScale = myShapeScaleMap->Find(theShape);
|
||||
if ((aScale - theScale).Modulus() > Precision::Confusion())
|
||||
{
|
||||
// Create a shape copy to avoid problems with different scaling
|
||||
BRepBuilderAPI_Copy aCopy;
|
||||
aCopy.Perform(theShape, Standard_True, Standard_True);
|
||||
theShape = aCopy.Shape();
|
||||
}
|
||||
}
|
||||
|
||||
TopoDS_Shape aShape = theShape;
|
||||
if (!theLoc.IsIdentity())
|
||||
{
|
||||
@@ -2491,11 +2453,6 @@ void RWGltf_GltfJsonParser::bindNamedShape(TopoDS_Shape& the
|
||||
}
|
||||
myAttribMap->Bind(theShape, aShapeAttribs);
|
||||
}
|
||||
|
||||
if (theHasScale)
|
||||
{
|
||||
myShapeScaleMap->Bind(theShape, theScale);
|
||||
}
|
||||
myShapeMap[theGroup].Bind(theId, theShape);
|
||||
}
|
||||
|
||||
@@ -2504,7 +2461,18 @@ void RWGltf_GltfJsonParser::bindNamedShape(TopoDS_Shape& the
|
||||
bool RWGltf_GltfJsonParser::fillMeshData(
|
||||
const Handle(RWGltf_GltfLatePrimitiveArray)& theMeshData) const
|
||||
{
|
||||
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||
if (myStream == nullptr)
|
||||
{
|
||||
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||
myStream = aFileSystem->OpenIStream(myFilePath, std::ios::in | std::ios::binary);
|
||||
}
|
||||
|
||||
if (myStream == nullptr)
|
||||
{
|
||||
reportGltfError("Buffer '" + myFilePath + "' isn't defined.");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (NCollection_Sequence<RWGltf_GltfPrimArrayData>::Iterator aDataIter(theMeshData->Data());
|
||||
aDataIter.More();
|
||||
aDataIter.Next())
|
||||
@@ -2513,24 +2481,8 @@ bool RWGltf_GltfJsonParser::fillMeshData(
|
||||
|
||||
Handle(RWGltf_TriangulationReader) aReader = new RWGltf_TriangulationReader();
|
||||
aReader->SetCoordinateSystemConverter(myCSTrsf);
|
||||
std::shared_ptr<std::istream> aNewStream;
|
||||
if (myStream != nullptr)
|
||||
{
|
||||
aNewStream = myStream;
|
||||
aNewStream->seekg(aData.StreamOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
aNewStream = aFileSystem->OpenIStream(aData.StreamUri,
|
||||
std::ios::in | std::ios::binary,
|
||||
aData.StreamOffset);
|
||||
}
|
||||
|
||||
if (aNewStream == nullptr)
|
||||
{
|
||||
reportGltfError("Buffer '" + aData.StreamUri + "' isn't defined.");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<std::istream> aNewStream = myStream;
|
||||
aNewStream->seekg(aData.StreamOffset);
|
||||
|
||||
if (!aReader
|
||||
->ReadStream(theMeshData, theMeshData, *aNewStream.get(), aData.Accessor, aData.Type))
|
||||
|
@@ -81,12 +81,6 @@ public:
|
||||
//! Set map for storing node attributes.
|
||||
void SetAttributeMap(RWMesh_NodeAttributeMap& theAttribMap) { myAttribMap = &theAttribMap; }
|
||||
|
||||
//! Set map for storing non-uniform scalings.
|
||||
void SetScaleMap(NCollection_DataMap<TopoDS_Shape, gp_XYZ, TopTools_ShapeMapHasher>& theScaleMap)
|
||||
{
|
||||
myShapeScaleMap = &theScaleMap;
|
||||
}
|
||||
|
||||
//! Set list for storing external files.
|
||||
void SetExternalFiles(NCollection_IndexedMap<TCollection_AsciiString>& theExternalFiles)
|
||||
{
|
||||
@@ -126,10 +120,6 @@ public:
|
||||
//! Set flag to use Mesh name in case if Node name is empty, TRUE by default.
|
||||
void SetMeshNameAsFallback(bool theToFallback) { myUseMeshNameAsFallback = theToFallback; }
|
||||
|
||||
//! Set flag to apply non-uniform scaling directly to the triangulation (modify nodes).
|
||||
//! TRUE by default. In case of FALSE the average scale is applied to the transformation matrix.
|
||||
void SetToApplyScale(bool theToApplyScale) { myToApplyScale = theToApplyScale; }
|
||||
|
||||
//! Parse glTF document.
|
||||
Standard_EXPORT bool Parse(const Message_ProgressRange& theProgress);
|
||||
|
||||
@@ -299,20 +289,11 @@ protected:
|
||||
//! Bind name attribute.
|
||||
void bindNodeShape(TopoDS_Shape& theShape,
|
||||
const TopLoc_Location& theLoc,
|
||||
const bool theHasScale,
|
||||
const gp_XYZ& theScale,
|
||||
const TCollection_AsciiString& theNodeId,
|
||||
const RWGltf_JsonValue* theUserName,
|
||||
const Handle(TDataStd_NamedData)& theExtras)
|
||||
{
|
||||
bindNamedShape(theShape,
|
||||
ShapeMapGroup_Nodes,
|
||||
theLoc,
|
||||
theHasScale,
|
||||
theScale,
|
||||
theNodeId,
|
||||
theUserName,
|
||||
theExtras);
|
||||
bindNamedShape(theShape, ShapeMapGroup_Nodes, theLoc, theNodeId, theUserName, theExtras);
|
||||
}
|
||||
|
||||
//! Bind name attribute.
|
||||
@@ -324,8 +305,6 @@ protected:
|
||||
bindNamedShape(theShape,
|
||||
ShapeMapGroup_Meshes,
|
||||
TopLoc_Location(),
|
||||
false,
|
||||
gp_XYZ(),
|
||||
theMeshId,
|
||||
theUserName,
|
||||
theExtras);
|
||||
@@ -347,8 +326,6 @@ protected:
|
||||
Standard_EXPORT void bindNamedShape(TopoDS_Shape& theShape,
|
||||
ShapeMapGroup theGroup,
|
||||
const TopLoc_Location& theLoc,
|
||||
const bool theHasScale,
|
||||
const gp_XYZ& theScale,
|
||||
const TCollection_AsciiString& theId,
|
||||
const RWGltf_JsonValue* theUserName,
|
||||
const Handle(TDataStd_NamedData)& theExtras);
|
||||
@@ -440,18 +417,13 @@ private:
|
||||
//! @param theTranslationVal Json value containing translation component of transformation.
|
||||
//! May be null in which case it is ignored.
|
||||
//! @param theResult TopLoc_Location object where result of parsing will be written.
|
||||
//! @param theHasScale The flag indicates if scale component was found in the transformation.
|
||||
//! @param theScale Found scale vector. Only valid if @p theHasScale is true.
|
||||
//! Otherwise, it is undefined.
|
||||
//! @param If true - parsing was successful, transformation is written into @p theResult.
|
||||
//! If true - failed to parse, @p theResult is unchanged.
|
||||
bool parseTransformationComponents(const TCollection_AsciiString& theSceneNodeId,
|
||||
const RWGltf_JsonValue* theRotationVal,
|
||||
const RWGltf_JsonValue* theScaleVal,
|
||||
const RWGltf_JsonValue* theTranslationVal,
|
||||
TopLoc_Location& theResult,
|
||||
bool& theHasScale,
|
||||
gp_XYZ& theScale) const;
|
||||
TopLoc_Location& theResult) const;
|
||||
|
||||
//! Fill lines and points data not deferred.
|
||||
//! @param theMeshData source glTF triangulation
|
||||
@@ -467,9 +439,7 @@ protected:
|
||||
TopTools_SequenceOfShape* myRootShapes; //!< sequence of result root shapes
|
||||
RWMesh_NodeAttributeMap* myAttribMap; //!< shape attributes
|
||||
NCollection_IndexedMap<TCollection_AsciiString>*
|
||||
myExternalFiles; //!< list of external file references
|
||||
NCollection_DataMap<TopoDS_Shape, gp_XYZ, TopTools_ShapeMapHasher>*
|
||||
myShapeScaleMap; //!< map of shapes with non-uniform scalings
|
||||
myExternalFiles; //!< list of external file references
|
||||
// clang-format off
|
||||
RWMesh_CoordinateSystemConverter myCSTrsf; //!< transformation from glTF to OCCT coordinate system
|
||||
// clang-format on
|
||||
@@ -500,7 +470,6 @@ protected:
|
||||
bool myUseMeshNameAsFallback; //!< flag to use Mesh name in case if Node name is empty, TRUE by default
|
||||
bool myToProbeHeader; //!< flag to probe header without full reading, FALSE by default
|
||||
bool myToReadAssetExtras; //!< flag to translate asset.extras into metadata, TRUE by default
|
||||
bool myToApplyScale; //!< flag to apply non-uniform scaling
|
||||
// clang-format on
|
||||
|
||||
#ifdef HAVE_RAPIDJSON
|
||||
|
@@ -317,13 +317,6 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferShape(
|
||||
|
||||
Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferEdge(const TopoDS_Edge& myedge)
|
||||
{
|
||||
Standard_Integer anInd = IndexEdge(myedge);
|
||||
if (anInd != 0)
|
||||
{
|
||||
Handle(IGESData_IGESEntity) ICurve3d = Handle(IGESData_IGESEntity)::DownCast(myCurves(anInd));
|
||||
if (!ICurve3d.IsNull())
|
||||
return ICurve3d;
|
||||
}
|
||||
BRepToIGES_BRWire BR(*this);
|
||||
BR.SetModel(GetModel());
|
||||
TopTools_DataMapOfShapeShape anEmptyMap;
|
||||
|
@@ -2,5 +2,4 @@
|
||||
set(OCCT_TKDEIGES_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(OCCT_TKDEIGES_GTests_FILES
|
||||
IGESExportTest.cxx
|
||||
)
|
||||
|
@@ -1,54 +0,0 @@
|
||||
// Copyright (c) 2025 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <IGESData_IGESEntity.hxx>
|
||||
#include <IGESData_IGESModel.hxx>
|
||||
#include <IGESGeom_Line.hxx>
|
||||
#include <IGESControl_Writer.hxx>
|
||||
#include <Transfer_SimpleBinderOfTransient.hxx>
|
||||
#include <Transfer_FinderProcess.hxx>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// Check that 2d curves of shared edges are not lost in BRep mode.
|
||||
TEST(IGESExportTest, SharedCurvesBRepMode)
|
||||
{
|
||||
TopoDS_Shape aSolid = (TopoDS_Solid)BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 1, 1, 1);
|
||||
|
||||
Standard_Integer aBRepMode = 1;
|
||||
IGESControl_Writer aWriter("MM", aBRepMode);
|
||||
aWriter.AddShape(aSolid);
|
||||
|
||||
const Handle(Transfer_FinderProcess)& aFP = aWriter.TransferProcess();
|
||||
const Handle(IGESData_IGESModel)& aModel = aWriter.Model();
|
||||
|
||||
for (Standard_Integer i = 1; i <= aFP->NbMapped(); i++)
|
||||
{
|
||||
Handle(Transfer_SimpleBinderOfTransient) aBinder =
|
||||
Handle(Transfer_SimpleBinderOfTransient)::DownCast(aFP->MapItem(i));
|
||||
if (aBinder.IsNull())
|
||||
continue;
|
||||
|
||||
Handle(IGESData_IGESEntity) anEnt = Handle(IGESData_IGESEntity)::DownCast(aBinder->Result());
|
||||
if (anEnt.IsNull())
|
||||
continue;
|
||||
|
||||
Handle(IGESGeom_Line) aLine = Handle(IGESGeom_Line)::DownCast(anEnt);
|
||||
if (aLine.IsNull())
|
||||
continue;
|
||||
|
||||
// Check that all the entities are in the model.
|
||||
EXPECT_TRUE(aModel->DNum(anEnt) != 0);
|
||||
}
|
||||
}
|
@@ -237,7 +237,10 @@ Handle(StepVisual_SurfaceStyleRenderingWithProperties) STEPConstruct_RenderingPr
|
||||
// Add transparency
|
||||
Handle(StepVisual_SurfaceStyleTransparent) aTransparent = new StepVisual_SurfaceStyleTransparent;
|
||||
aTransparent->Init(myTransparency);
|
||||
aProps->ChangeValue(aPropIndex++).SetValue(aTransparent);
|
||||
|
||||
StepVisual_RenderingPropertiesSelect aRPS;
|
||||
aRPS.SetValue(aTransparent);
|
||||
aProps->SetValue(aPropIndex++, aRPS);
|
||||
|
||||
// Add the appropriate reflectance model based on what we have
|
||||
if (hasAmbientOnly)
|
||||
@@ -247,7 +250,9 @@ Handle(StepVisual_SurfaceStyleRenderingWithProperties) STEPConstruct_RenderingPr
|
||||
new StepVisual_SurfaceStyleReflectanceAmbient;
|
||||
aAmbient->Init(myAmbientReflectance.first);
|
||||
|
||||
aProps->ChangeValue(aPropIndex++).SetValue(aAmbient);
|
||||
StepVisual_RenderingPropertiesSelect aRPS;
|
||||
aRPS.SetValue(aAmbient);
|
||||
aProps->SetValue(aPropIndex++, aRPS);
|
||||
}
|
||||
else if (hasDiffuseAndAmbient)
|
||||
{
|
||||
@@ -256,7 +261,9 @@ Handle(StepVisual_SurfaceStyleRenderingWithProperties) STEPConstruct_RenderingPr
|
||||
new StepVisual_SurfaceStyleReflectanceAmbientDiffuse;
|
||||
aAmbientDiffuse->Init(myAmbientReflectance.first, myDiffuseReflectance.first);
|
||||
|
||||
aProps->ChangeValue(aPropIndex++).SetValue(aAmbientDiffuse);
|
||||
StepVisual_RenderingPropertiesSelect aRPS;
|
||||
aRPS.SetValue(aAmbientDiffuse);
|
||||
aProps->SetValue(aPropIndex++, aRPS);
|
||||
}
|
||||
else if (hasFullReflectance)
|
||||
{
|
||||
@@ -270,7 +277,9 @@ Handle(StepVisual_SurfaceStyleRenderingWithProperties) STEPConstruct_RenderingPr
|
||||
mySpecularExponent.first,
|
||||
STEPConstruct_Styles::EncodeColor(mySpecularColour.first));
|
||||
|
||||
aProps->ChangeValue(aPropIndex++).SetValue(aFullRefl);
|
||||
StepVisual_RenderingPropertiesSelect aRPS;
|
||||
aRPS.SetValue(aFullRefl);
|
||||
aProps->SetValue(aPropIndex++, aRPS);
|
||||
}
|
||||
|
||||
// Create STEP surface style rendering with properties
|
||||
@@ -295,7 +304,7 @@ XCAFDoc_VisMaterialCommon STEPConstruct_RenderingProperties::CreateXCAFMaterial(
|
||||
|
||||
// Use surface color as the base diffuse color
|
||||
aMaterial.DiffuseColor = mySurfaceColor;
|
||||
aMaterial.Transparency = static_cast<float>(myTransparency);
|
||||
aMaterial.Transparency = myTransparency;
|
||||
aMaterial.IsDefined = Standard_True;
|
||||
|
||||
// Set default values for other properties
|
||||
@@ -391,7 +400,7 @@ void STEPConstruct_RenderingProperties::Init(
|
||||
{
|
||||
for (Standard_Integer i = 1; i <= aProperties->Length(); i++)
|
||||
{
|
||||
const StepVisual_RenderingPropertiesSelect& aPropSelect = aProperties->Value(i);
|
||||
StepVisual_RenderingPropertiesSelect aPropSelect = aProperties->Value(i);
|
||||
|
||||
// Check for transparency
|
||||
Handle(StepVisual_SurfaceStyleTransparent) aTransparent =
|
||||
|
@@ -144,7 +144,7 @@ public:
|
||||
//! @return ColorRGBA object
|
||||
Quantity_ColorRGBA GetRGBAColor() const
|
||||
{
|
||||
return Quantity_ColorRGBA(mySurfaceColor, static_cast<float>(1.0 - myTransparency));
|
||||
return Quantity_ColorRGBA(mySurfaceColor, 1.0 - myTransparency);
|
||||
}
|
||||
|
||||
//! Returns surface color
|
||||
|
@@ -58,7 +58,7 @@ public:
|
||||
//! has been made on the spot, it is assumed to cause no change
|
||||
//! to the graph of dependances
|
||||
//! - if it equates the starting Model, it has been transformed on
|
||||
//! the spot (possibly some entities were replaced inside it)
|
||||
//! the spot (possibiliy some entities were replaced inside it)
|
||||
//! - if it is new, it corresponds to a new data set which replaces
|
||||
//! the starting one
|
||||
//!
|
||||
|
@@ -119,7 +119,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
|
||||
Standard_Boolean toPrintDebugInfo = Standard_False;
|
||||
Standard_Boolean toLoadAllScenes = Standard_False;
|
||||
Standard_Boolean toPrintAssetInfo = Standard_False;
|
||||
Standard_Boolean toApplyScale = Standard_True;
|
||||
Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readgltf");
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
|
||||
{
|
||||
@@ -168,10 +167,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
|
||||
{
|
||||
toPrintAssetInfo = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
|
||||
}
|
||||
else if (anArgCase == "-applyscale")
|
||||
{
|
||||
toApplyScale = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
|
||||
}
|
||||
else if (aDestName.IsEmpty())
|
||||
{
|
||||
aDestName = theArgVec[anArgIter];
|
||||
@@ -234,7 +229,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
|
||||
aReader.SetToKeepLateData(toKeepLateData);
|
||||
aReader.SetToPrintDebugMessages(toPrintDebugInfo);
|
||||
aReader.SetLoadAllScenes(toLoadAllScenes);
|
||||
aReader.SetToApplyScale(toApplyScale);
|
||||
if (aDestName.IsEmpty())
|
||||
{
|
||||
aReader.ProbeHeader(aFilePath);
|
||||
@@ -529,10 +523,7 @@ void XSDRAWGLTF::Factory(Draw_Interpretor& theDI)
|
||||
"\n\t\t: -allScenes load all scenes defined in the document instead of default one "
|
||||
"(false by default)"
|
||||
"\n\t\t: -toPrintDebugInfo print additional debug information during data reading"
|
||||
"\n\t\t: -assetInfo print asset information"
|
||||
"\n\t\t: -applyScale apply non-uniform scaling directly to the triangulation (modify "
|
||||
"\n\t\t: nodes) (true by default). In case of false the average scale is "
|
||||
"\n\t\t: applied to the transformation matrix.",
|
||||
"\n\t\t: -assetInfo print asset information",
|
||||
__FILE__,
|
||||
ReadGltf,
|
||||
aGroup);
|
||||
|
@@ -220,7 +220,7 @@ static Standard_Integer igesbrep(Draw_Interpretor& theDI,
|
||||
<< std::flush;
|
||||
modepri = -1;
|
||||
|
||||
// amv 26.09.2003 : this is used to avoid error of enter's symbol
|
||||
// amv 26.09.2003 : this is used to avoid error of enter's simbol
|
||||
char str[80];
|
||||
std::cin >> str;
|
||||
modepri = Draw::Atoi(str);
|
||||
@@ -427,7 +427,7 @@ static Standard_Integer igesbrep(Draw_Interpretor& theDI,
|
||||
if (list.IsNull())
|
||||
{
|
||||
theDI
|
||||
<< "No list defined. Give a selection name or * for all visible transferable roots\n";
|
||||
<< "No list defined. Give a selection name or * for all visible transferrable roots\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -26,12 +26,7 @@
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_DataMapOfIntegerInteger.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
class gp_Pln;
|
||||
class Bnd_VoxelGrid;
|
||||
|
||||
//! A tool to compare a bounding box or a plane with a set of
|
||||
//! bounding boxes. It sorts the set of bounding boxes to give
|
||||
@@ -40,111 +35,90 @@ class Bnd_VoxelGrid;
|
||||
//! while the box being compared bounds a shape to be
|
||||
//! compared. The resulting list of intersecting boxes therefore
|
||||
//! gives the list of items which potentially intersect the shape to be compared.
|
||||
//! How to use this class:
|
||||
//! - Create an instance of this class.
|
||||
//! - Initialize it with the set of boxes to be sorted using one of the
|
||||
//! Initialize() methods.
|
||||
//! - Call the Compare() method with the box or plane to be compared.
|
||||
//! Compare() will return the list of indices of the boxes which intersect
|
||||
//! the box or plane passed as argument.
|
||||
class Bnd_BoundSortBox
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
private:
|
||||
using VectorInt = std::vector<Standard_Integer, NCollection_Allocator<Standard_Integer>>;
|
||||
|
||||
public:
|
||||
//! Constructs an empty comparison algorithm for bounding boxes.
|
||||
//! The bounding boxes are then defined using the Initialize function.
|
||||
Standard_EXPORT Bnd_BoundSortBox();
|
||||
|
||||
//! Initializes this comparison algorithm with the set of boxes.
|
||||
//! @param theSetOfBoxes The set of bounding boxes to be used by this algorithm.
|
||||
Standard_EXPORT void Initialize(const Handle(Bnd_HArray1OfBox)& theSetOfBoxes);
|
||||
//! Initializes this comparison algorithm with
|
||||
//! - the set of bounding boxes SetOfBox.
|
||||
Standard_EXPORT void Initialize(const Bnd_Box& CompleteBox,
|
||||
const Handle(Bnd_HArray1OfBox)& SetOfBox);
|
||||
|
||||
//! Initializes this comparison algorithm with the set of boxes and the bounding box
|
||||
//! that encloses all those boxes. This version of initialization can be used if complete
|
||||
//! box is known in advance to avoid calculating it again inside the algorithm.
|
||||
//! @param theEnclosingBox The bounding box that contains all the boxes in @p theSetOfBoxes.
|
||||
//! @param theSetOfBoxes The set of bounding boxes to be used by this algorithm.
|
||||
Standard_EXPORT void Initialize(const Bnd_Box& theEnclosingBox,
|
||||
const Handle(Bnd_HArray1OfBox)& theSetOfBoxes);
|
||||
//! Initializes this comparison algorithm with
|
||||
//! - the set of bounding boxes SetOfBox, where
|
||||
//! CompleteBox is given as the global bounding box of SetOfBox.
|
||||
Standard_EXPORT void Initialize(const Handle(Bnd_HArray1OfBox)& SetOfBox);
|
||||
|
||||
//! Initializes this comparison algorithm with the bounding box that encloses all the boxes
|
||||
//! that will be used by this algorithm. and the expected number of those boxes.
|
||||
//! Boxes to be considered can then be added using the Add() method.
|
||||
//! @param theEnclosingBox The bounding box that contains all the boxes to be sorted.
|
||||
//! @param theNbComponents The number of components to be added.
|
||||
Standard_EXPORT void Initialize(const Bnd_Box& theEnclosingBox,
|
||||
const Standard_Integer theNbBoxes);
|
||||
//! Initializes this comparison algorithm, giving it only
|
||||
//! - the maximum number nbComponents
|
||||
//! of the bounding boxes to be managed. Use the Add
|
||||
//! function to define the array of bounding boxes to be sorted by this algorithm.
|
||||
Standard_EXPORT void Initialize(const Bnd_Box& CompleteBox, const Standard_Integer nbComponents);
|
||||
|
||||
//! Adds the bounding box theBox at position boxIndex in the internal array of boxes
|
||||
//! to be sorted by this comparison algorithm. This function is used only in
|
||||
//! conjunction with the Initialize(const Bnd_Box&, const Standard_Integer) method.
|
||||
//! Adds the bounding box theBox at position boxIndex in
|
||||
//! the array of boxes to be sorted by this comparison algorithm.
|
||||
//! This function is used only in conjunction with the third
|
||||
//! syntax described in the synopsis of Initialize.
|
||||
//!
|
||||
//! Exceptions:
|
||||
//! - Standard_OutOfRange if boxIndex is not in the range [ 1,nbComponents ] where
|
||||
//! nbComponents is the maximum number of bounding boxes declared for this algorithm at
|
||||
//! initialization.
|
||||
//! - Standard_MultiplyDefined if a box already exists at position @p theIndex in the
|
||||
//! internal array of boxes.
|
||||
//! @param theBox The bounding box to be added.
|
||||
//! @param theIndex The index of the bounding box in the internal array where the box
|
||||
//! will be added. The index is 1-based.
|
||||
Standard_EXPORT void Add(const Bnd_Box& theBox, const Standard_Integer theIndex);
|
||||
//!
|
||||
//! - Standard_OutOfRange if boxIndex is not in the
|
||||
//! range [ 1,nbComponents ] where
|
||||
//! nbComponents is the maximum number of bounding
|
||||
//! boxes declared for this comparison algorithm at
|
||||
//! initialization.
|
||||
//!
|
||||
//! - Standard_MultiplyDefined if a box already exists at
|
||||
//! position boxIndex in the array of boxes to be sorted by
|
||||
//! this comparison algorithm.
|
||||
Standard_EXPORT void Add(const Bnd_Box& theBox, const Standard_Integer boxIndex);
|
||||
|
||||
//! Compares the bounding box theBox, with the set of bounding boxes provided to this
|
||||
//! algorithm at initialization, and returns the list of indices of bounding boxes
|
||||
//! that intersect the @p theBox or are inside it.
|
||||
//! The indices correspond to the indices of the bounding boxes in the array provided
|
||||
//! to this algorithm at initialization.
|
||||
//! @param theBox The bounding box to be compared.
|
||||
//! @return The list of indices of bounding boxes that intersect the bounding box theBox
|
||||
//! or are inside it.
|
||||
//! Compares the bounding box theBox,
|
||||
//! with the set of bounding boxes to be sorted by this
|
||||
//! comparison algorithm, and returns the list of intersecting
|
||||
//! bounding boxes as a list of indexes on the array of
|
||||
//! bounding boxes used by this algorithm.
|
||||
Standard_EXPORT const TColStd_ListOfInteger& Compare(const Bnd_Box& theBox);
|
||||
|
||||
//! Compares the plane @p thePlane with the set of bounding boxes provided to this
|
||||
//! algorithm at initialization, and returns the list of indices of bounding boxes
|
||||
//! that intersect the @p thePlane.
|
||||
//! The indices correspond to the indices of the bounding boxes in the array provided
|
||||
//! to this algorithm at initialization.
|
||||
//! @param thePlane The plane to be compared.
|
||||
//! @return The list of indices of bounding boxes that intersect the plane thePlane.
|
||||
Standard_EXPORT const TColStd_ListOfInteger& Compare(const gp_Pln& thePlane);
|
||||
//! Compares the plane P
|
||||
//! with the set of bounding boxes to be sorted by this
|
||||
//! comparison algorithm, and returns the list of intersecting
|
||||
//! bounding boxes as a list of indexes on the array of
|
||||
//! bounding boxes used by this algorithm.
|
||||
Standard_EXPORT const TColStd_ListOfInteger& Compare(const gp_Pln& P);
|
||||
|
||||
Standard_EXPORT void Dump() const;
|
||||
|
||||
Standard_EXPORT void Destroy();
|
||||
|
||||
~Bnd_BoundSortBox() { Destroy(); }
|
||||
|
||||
protected:
|
||||
private:
|
||||
//! Precalculates the coefficients for the voxel grid based on the enclosing box dimensions.
|
||||
//! The coefficients will be used to map the box coordinates to the voxel grid.
|
||||
void calculateCoefficients();
|
||||
//! Prepares BoundSortBox and sorts the boxes of
|
||||
//! <SetOfBox> .
|
||||
Standard_EXPORT void SortBoxes();
|
||||
|
||||
//! Resets the voxel grid and clears the list of large boxes.
|
||||
void resetVoxelGrid();
|
||||
|
||||
//! Performs the sorting of the boxes in the voxel grid.
|
||||
//! This method is called after the boxes have been added to the voxel grid.
|
||||
void sortBoxes();
|
||||
|
||||
//! Returns indices of voxels that contain minimum and maximum points of the box.
|
||||
//! @param theBox The bounding box to be compared.
|
||||
//! @return The indices of the voxels that contain the minimum and maximum points of the box
|
||||
//! in the order: [minX, minY, minZ, maxX, maxY, maxZ].
|
||||
std::array<Standard_Integer, 6> getBoundingVoxels(const Bnd_Box& theBox) const;
|
||||
|
||||
//! Adds the box stored in myBoxes to the voxel map.
|
||||
//! @param theBox The bounding box to be added.
|
||||
//! @param theIndex The index of the bounding box in myBoxes.
|
||||
void addBox(const Bnd_Box& theBox, const Standard_Integer theIndex);
|
||||
|
||||
Bnd_Box myEnclosingBox; //!< The bounding box that contains all the boxes to be sorted.
|
||||
Handle(Bnd_HArray1OfBox) myBoxes; //!< The set of bounding boxes to be sorted.
|
||||
Standard_Real myCoeffX; //!< Coefficient for X direction.
|
||||
Standard_Real myCoeffY; //!< Coefficient for Y direction.
|
||||
Standard_Real myCoeffZ; //!< Coefficient for Z direction.
|
||||
Standard_Integer myResolution; //!< The number of voxels in each direction.
|
||||
TColStd_ListOfInteger myLastResult; //!< The last result of the Compare() method.
|
||||
VectorInt myLargeBoxes; //!< The list of large boxes.
|
||||
Handle(Bnd_VoxelGrid) myVoxelGrid; //!< The voxel grid used for sorting the boxes.
|
||||
Bnd_Box myBox;
|
||||
Handle(Bnd_HArray1OfBox) myBndComponents;
|
||||
Standard_Real Xmin;
|
||||
Standard_Real Ymin;
|
||||
Standard_Real Zmin;
|
||||
Standard_Real deltaX;
|
||||
Standard_Real deltaY;
|
||||
Standard_Real deltaZ;
|
||||
Standard_Integer discrX;
|
||||
Standard_Integer discrY;
|
||||
Standard_Integer discrZ;
|
||||
Standard_Integer theFound;
|
||||
TColStd_DataMapOfIntegerInteger Crible;
|
||||
TColStd_ListOfInteger lastResult;
|
||||
Standard_Address TabBits;
|
||||
};
|
||||
|
||||
#endif // _Bnd_BoundSortBox_HeaderFile
|
||||
|
@@ -1,256 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <Bnd_BoundSortBox.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <Bnd_HArray1OfBox.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
|
||||
#include <random>
|
||||
#include <chrono>
|
||||
|
||||
// Helper function to create a box from min and max points
|
||||
static Bnd_Box CreateBox(const Standard_Real xmin, const Standard_Real ymin, const Standard_Real zmin,
|
||||
const Standard_Real xmax, const Standard_Real ymax, const Standard_Real zmax)
|
||||
{
|
||||
Bnd_Box box;
|
||||
box.Update(xmin, ymin, zmin, xmax, ymax, zmax);
|
||||
return box;
|
||||
}
|
||||
|
||||
// Test fixture for Bnd_BoundSortBox tests
|
||||
class Bnd_BoundSortBoxTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
// Setup common testing environment
|
||||
mySmallBox = CreateBox(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
|
||||
myLargeBox = CreateBox(-10.0, -10.0, -10.0, 10.0, 10.0, 10.0);
|
||||
myOffsetBox = CreateBox(5.0, 5.0, 5.0, 7.0, 7.0, 7.0);
|
||||
myNonIntersectingBox = CreateBox(20.0, 20.0, 20.0, 30.0, 30.0, 30.0);
|
||||
|
||||
// Create array of test boxes
|
||||
myBoxes = new Bnd_HArray1OfBox(1, 4);
|
||||
myBoxes->SetValue(1, mySmallBox);
|
||||
myBoxes->SetValue(2, myLargeBox);
|
||||
myBoxes->SetValue(3, myOffsetBox);
|
||||
myBoxes->SetValue(4, myNonIntersectingBox);
|
||||
|
||||
// Create a global bounding box that contains all test boxes
|
||||
myGlobalBox = CreateBox(-20.0, -20.0, -20.0, 40.0, 40.0, 40.0);
|
||||
}
|
||||
|
||||
// Common test data
|
||||
Bnd_Box mySmallBox;
|
||||
Bnd_Box myLargeBox;
|
||||
Bnd_Box myOffsetBox;
|
||||
Bnd_Box myNonIntersectingBox;
|
||||
Bnd_Box myGlobalBox;
|
||||
Handle(Bnd_HArray1OfBox) myBoxes;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
// Test initialization with set of boxes
|
||||
TEST_F(Bnd_BoundSortBoxTest, InitializeWithBoxes)
|
||||
{
|
||||
Bnd_BoundSortBox sortBox;
|
||||
sortBox.Initialize(myBoxes);
|
||||
|
||||
// Test comparing with a box that intersects mySmallBox
|
||||
Bnd_Box testBox = CreateBox(0.5, 0.5, 0.5, 1.5, 1.5, 1.5);
|
||||
const TColStd_ListOfInteger& result = sortBox.Compare(testBox);
|
||||
|
||||
EXPECT_EQ(2, result.Extent()) << "Expected to find 2 intersections";
|
||||
|
||||
// Check that box indices 1 (mySmallBox) and 2 (myLargeBox) are in the result
|
||||
bool foundSmall = false;
|
||||
bool foundLarge = false;
|
||||
for (TColStd_ListOfInteger::Iterator it(result); it.More(); it.Next()) {
|
||||
if (it.Value() == 1) foundSmall = true;
|
||||
if (it.Value() == 2) foundLarge = true;
|
||||
}
|
||||
EXPECT_TRUE(foundSmall) << "Small box (index 1) should be in the result";
|
||||
EXPECT_TRUE(foundLarge) << "Large box (index 2) should be in the result";
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
// Test initialization with provided enclosing box
|
||||
TEST_F(Bnd_BoundSortBoxTest, InitializeWithEnclosingBox)
|
||||
{
|
||||
Bnd_BoundSortBox sortBox;
|
||||
sortBox.Initialize(myGlobalBox, myBoxes);
|
||||
|
||||
// Test comparing with myOffsetBox
|
||||
const TColStd_ListOfInteger& result = sortBox.Compare(myOffsetBox);
|
||||
|
||||
EXPECT_EQ(2, result.Extent()) << "Expected to find 2 intersections";
|
||||
|
||||
// Check that box indices 2 (myLargeBox) and 3 (myOffsetBox) are in the result
|
||||
bool foundLarge = false;
|
||||
bool foundOffset = false;
|
||||
for (TColStd_ListOfInteger::Iterator it(result); it.More(); it.Next()) {
|
||||
if (it.Value() == 2) foundLarge = true;
|
||||
if (it.Value() == 3) foundOffset = true;
|
||||
}
|
||||
EXPECT_TRUE(foundLarge) << "Large box (index 2) should be in the result";
|
||||
EXPECT_TRUE(foundOffset) << "Offset box (index 3) should be in the result";
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
// Test initialization with enclosing box and expected count
|
||||
TEST_F(Bnd_BoundSortBoxTest, InitializeWithCount)
|
||||
{
|
||||
Bnd_BoundSortBox sortBox;
|
||||
sortBox.Initialize(myGlobalBox, 3);
|
||||
|
||||
// Add boxes manually
|
||||
sortBox.Add(mySmallBox, 1);
|
||||
sortBox.Add(myLargeBox, 2);
|
||||
sortBox.Add(myNonIntersectingBox, 3);
|
||||
|
||||
// Test comparing with a box that should only intersect myLargeBox
|
||||
Bnd_Box testBox = CreateBox(-5.0, -5.0, -5.0, -2.0, -2.0, -2.0);
|
||||
const TColStd_ListOfInteger& result = sortBox.Compare(testBox);
|
||||
|
||||
EXPECT_EQ(1, result.Extent()) << "Expected to find 1 intersection";
|
||||
|
||||
// Verify that only the large box was found
|
||||
EXPECT_EQ(2, result.First()) << "Large box (index 2) should be the only result";
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
// Test comparing with a plane
|
||||
TEST_F(Bnd_BoundSortBoxTest, CompareWithPlane)
|
||||
{
|
||||
Bnd_BoundSortBox sortBox;
|
||||
sortBox.Initialize(myBoxes);
|
||||
|
||||
// Create a plane that intersects the large box but not others
|
||||
gp_Pnt point(0.0, 0.0, 9.0);
|
||||
gp_Dir direction(0.0, 0.0, 1.0);
|
||||
gp_Pln plane(point, direction);
|
||||
|
||||
const TColStd_ListOfInteger& result = sortBox.Compare(plane);
|
||||
|
||||
// Only the large box should intersect this plane
|
||||
EXPECT_EQ(1, result.Extent()) << "Expected to find 1 intersection";
|
||||
EXPECT_EQ(2, result.First()) << "Large box (index 2) should be the only result";
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
// Test with void boxes
|
||||
TEST_F(Bnd_BoundSortBoxTest, VoidBoxes)
|
||||
{
|
||||
Handle(Bnd_HArray1OfBox) boxes = new Bnd_HArray1OfBox(1, 2);
|
||||
Bnd_Box void_box; // Default constructed box is void
|
||||
boxes->SetValue(1, void_box);
|
||||
boxes->SetValue(2, mySmallBox);
|
||||
|
||||
Bnd_BoundSortBox sortBox;
|
||||
sortBox.Initialize(boxes);
|
||||
|
||||
// Test comparing with mySmallBox - should only find itself
|
||||
const TColStd_ListOfInteger& result = sortBox.Compare(mySmallBox);
|
||||
|
||||
EXPECT_EQ(1, result.Extent()) << "Expected to find 1 intersection";
|
||||
EXPECT_EQ(2, result.First()) << "Small box (index 2) should be the only result";
|
||||
|
||||
// Test comparing with void box - should find nothing
|
||||
const TColStd_ListOfInteger& void_result = sortBox.Compare(void_box);
|
||||
EXPECT_EQ(0, void_result.Extent()) << "Expected to find 0 intersections with void box";
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
// Test with touching boxes
|
||||
TEST_F(Bnd_BoundSortBoxTest, TouchingBoxes)
|
||||
{
|
||||
// Create boxes that touch at a single point
|
||||
Bnd_Box box1 = CreateBox(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
|
||||
Bnd_Box box2 = CreateBox(1.0, 1.0, 1.0, 2.0, 2.0, 2.0); // Touches box1 at (1,1,1)
|
||||
|
||||
Handle(Bnd_HArray1OfBox) boxes = new Bnd_HArray1OfBox(1, 2);
|
||||
boxes->SetValue(1, box1);
|
||||
boxes->SetValue(2, box2);
|
||||
|
||||
Bnd_BoundSortBox sortBox;
|
||||
sortBox.Initialize(boxes);
|
||||
|
||||
// Test comparing with box1
|
||||
const TColStd_ListOfInteger& result1 = sortBox.Compare(box1);
|
||||
EXPECT_EQ(2, result1.Extent()) << "Expected to find 2 intersections";
|
||||
|
||||
// Test comparing with box2
|
||||
const TColStd_ListOfInteger& result2 = sortBox.Compare(box2);
|
||||
EXPECT_EQ(2, result2.Extent()) << "Expected to find 2 intersections";
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
// Test with boxes that are far apart
|
||||
TEST_F(Bnd_BoundSortBoxTest, DisjointBoxes)
|
||||
{
|
||||
Bnd_Box farBox = CreateBox(100.0, 100.0, 100.0, 110.0, 110.0, 110.0);
|
||||
|
||||
Handle(Bnd_HArray1OfBox) boxes = new Bnd_HArray1OfBox(1, 2);
|
||||
boxes->SetValue(1, mySmallBox);
|
||||
boxes->SetValue(2, farBox);
|
||||
|
||||
// Create enclosing box large enough
|
||||
Bnd_Box enclosingBox = CreateBox(-10.0, -10.0, -10.0, 120.0, 120.0, 120.0);
|
||||
|
||||
Bnd_BoundSortBox sortBox;
|
||||
sortBox.Initialize(enclosingBox, boxes);
|
||||
|
||||
// Test comparing with a box near mySmallBox
|
||||
Bnd_Box testBox = CreateBox(0.5, 0.5, 0.5, 1.5, 1.5, 1.5);
|
||||
const TColStd_ListOfInteger& result = sortBox.Compare(testBox);
|
||||
|
||||
EXPECT_EQ(1, result.Extent()) << "Expected to find 1 intersection";
|
||||
EXPECT_EQ(1, result.First()) << "Small box (index 1) should be the only result";
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
// Test with degenerate boxes (points, lines, planes)
|
||||
TEST_F(Bnd_BoundSortBoxTest, DegenerateBoxes)
|
||||
{
|
||||
// Create degenerate boxes
|
||||
Bnd_Box pointBox;
|
||||
pointBox.Update(1.0, 1.0, 1.0, 1.0, 1.0, 1.0); // Point at (1,1,1)
|
||||
|
||||
Bnd_Box lineBox;
|
||||
lineBox.Update(2.0, 0.0, 0.0, 5.0, 0.0, 0.0); // Line along X from (2,0,0) to (5,0,0)
|
||||
|
||||
Bnd_Box planeBox;
|
||||
planeBox.Update(0.0, 0.0, 3.0, 3.0, 3.0, 3.0); // XY plane at Z=3
|
||||
|
||||
Handle(Bnd_HArray1OfBox) boxes = new Bnd_HArray1OfBox(1, 3);
|
||||
boxes->SetValue(1, pointBox);
|
||||
boxes->SetValue(2, lineBox);
|
||||
boxes->SetValue(3, planeBox);
|
||||
|
||||
Bnd_BoundSortBox sortBox;
|
||||
sortBox.Initialize(boxes);
|
||||
|
||||
// Test with a box that should intersect all three degenerate boxes
|
||||
Bnd_Box testBox = CreateBox(0.0, 0.0, 0.0, 6.0, 6.0, 6.0);
|
||||
const TColStd_ListOfInteger& result = sortBox.Compare(testBox);
|
||||
|
||||
EXPECT_EQ(3, result.Extent()) << "Expected to find 3 intersections with degenerate boxes";
|
||||
|
||||
// Test with a box that should intersect only the point
|
||||
Bnd_Box pointTestBox = CreateBox(0.5, 0.5, 0.5, 1.5, 1.5, 1.5);
|
||||
const TColStd_ListOfInteger& pointResult = sortBox.Compare(pointTestBox);
|
||||
|
||||
EXPECT_EQ(1, pointResult.Extent()) << "Expected to find only the point box";
|
||||
EXPECT_EQ(1, pointResult.First()) << "Point box (index 1) should be the only result";
|
||||
}
|
@@ -2,6 +2,5 @@
|
||||
set(OCCT_TKMath_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(OCCT_TKMath_GTests_FILES
|
||||
Bnd_BoundSortBox_Test.cxx
|
||||
ElCLib_Test.cxx
|
||||
)
|
||||
|
@@ -411,7 +411,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1,
|
||||
for (k = 1; k <= yRoots1.NbSolutions(); k++)
|
||||
{
|
||||
y = yRoots1.Value(k);
|
||||
// Check if this value is already caught
|
||||
// Check if this value is already catched
|
||||
IsSame = Standard_False;
|
||||
for (l = 1; l < k; l++)
|
||||
if (Abs(y - yRoots1.Value(l)) <= 10 * Tolerance)
|
||||
@@ -436,7 +436,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1,
|
||||
for (k = 1; k <= yRoots1.NbSolutions(); k++)
|
||||
{
|
||||
y = yRoots1.Value(k);
|
||||
// Check if this value is already caught
|
||||
// Check if this value is already catched
|
||||
IsSame = Standard_False;
|
||||
FirstIndex = (i == 1) ? 1 : FirstSol(i);
|
||||
for (l = FirstIndex; l < CurSol; l++)
|
||||
@@ -527,7 +527,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1,
|
||||
p = -(b2 * y + d2) / a2;
|
||||
q = (c2 * (y * y) + 2 * e2 * y + f2) / a2;
|
||||
|
||||
// Check if this value is already caught
|
||||
// Check if this value is already catched
|
||||
IsSame = Standard_False;
|
||||
FirstIndex = (i == 1) ? 1 : FirstSol(i);
|
||||
for (l = FirstIndex; l < CurSol; l++)
|
||||
@@ -574,7 +574,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1,
|
||||
p = -(b2 * y + d2) / a2;
|
||||
q = (c2 * (y * y) + 2 * e2 * y + f2) / a2;
|
||||
|
||||
// Check if this value is already caught
|
||||
// Check if this value is already catched
|
||||
IsSame = Standard_False;
|
||||
for (l = 1; l < k; l++)
|
||||
if (Abs(y - yRoots.Value(l)) <= 10 * Tolerance)
|
||||
|
@@ -90,7 +90,7 @@ public:
|
||||
//! parametrisation sens of path (or of section if ExchangeUV)
|
||||
Standard_EXPORT Standard_Boolean VReversed() const;
|
||||
|
||||
//! Build the Sweeep Surface
|
||||
//! Build the Sweeep Surface
|
||||
//! ApproxStyle defines Approximation Strategy
|
||||
//! - GeomFill_Section : The composed Function : Location X Section
|
||||
//! is directly approximated.
|
||||
@@ -111,13 +111,13 @@ public:
|
||||
const Standard_Integer Degmax = 10,
|
||||
const Standard_Integer Segmax = 30);
|
||||
|
||||
//! Tells if the Surface is Built.
|
||||
//! Tells if the Surface is Buildt.
|
||||
Standard_EXPORT Standard_Boolean IsDone() const;
|
||||
|
||||
//! Gets the Approximation error.
|
||||
//! Gets the Approximation error.
|
||||
Standard_EXPORT Standard_Real ErrorOnSurface() const;
|
||||
|
||||
//! Gets the Approximation error.
|
||||
//! Gets the Approximation error.
|
||||
Standard_EXPORT void ErrorOnRestriction(const Standard_Boolean IsFirst,
|
||||
Standard_Real& UError,
|
||||
Standard_Real& VError) const;
|
||||
|
@@ -215,33 +215,12 @@ void BndLib_Add3dCurve::Add(const Adaptor3d_Curve& C,
|
||||
u2 = Bsaux->LastParameter();
|
||||
// modified by NIZHNY-EAP Fri Dec 3 14:29:18 1999 ___END___
|
||||
}
|
||||
const Standard_Real anU2Periodic =
|
||||
Bsaux->IsPeriodic() ? (u2 - (Bsaux->LastParameter() - Bsaux->FirstParameter())) : u2;
|
||||
Standard_Real aSegmentTol = 2. * Precision::PConfusion();
|
||||
|
||||
// For periodic curves, check if parameters are close in either direction
|
||||
if (Bsaux->IsPeriodic())
|
||||
if (Abs((anU2Periodic - u1) < aSegmentTol))
|
||||
{
|
||||
const Standard_Real aPeriod = Bsaux->LastParameter() - Bsaux->FirstParameter();
|
||||
|
||||
// Check direct distance between parameters
|
||||
const Standard_Real aDirectDiff = Abs(u2 - u1);
|
||||
|
||||
// Check distances across period boundary (in both directions)
|
||||
const Standard_Real aCrossPeriodDiff1 = Abs(u2 - aPeriod - u1);
|
||||
const Standard_Real aCrossPeriodDiff2 = Abs(u1 - aPeriod - u2);
|
||||
|
||||
// Find the minimum difference (closest approach)
|
||||
const Standard_Real aMinDiff =
|
||||
Min(aDirectDiff, Min(aCrossPeriodDiff1, aCrossPeriodDiff2));
|
||||
|
||||
if (aMinDiff < aSegmentTol)
|
||||
{
|
||||
aSegmentTol = aMinDiff * 0.01;
|
||||
}
|
||||
}
|
||||
// For non-periodic curves, just check direct parameter difference
|
||||
else if (Abs(u2 - u1) < aSegmentTol)
|
||||
{
|
||||
aSegmentTol = Abs(u2 - u1) * 0.01;
|
||||
aSegmentTol = Abs(anU2Periodic - u1) * 0.01;
|
||||
}
|
||||
Bsaux->Segment(u1, u2, aSegmentTol);
|
||||
Bs = Bsaux;
|
||||
|
@@ -236,7 +236,7 @@ void PrsDim_EqualDistanceRelation::ComputeSelection(const Handle(SelectMgr_Selec
|
||||
BRepAdaptor_Curve aCurve(TopoDS::Edge(myFShape));
|
||||
if (aCurve.GetType() == GeomAbs_Line)
|
||||
{
|
||||
// add sensitive element - line
|
||||
// add sensetive element - line
|
||||
seg = new Select3D_SensitiveSegment(own, myAttachPoint1, myPoint1);
|
||||
aSelection->Add(seg);
|
||||
}
|
||||
|
@@ -20,6 +20,6 @@ bop f1 f2
|
||||
bopsection result
|
||||
|
||||
checkprops result -l 13.7747
|
||||
checknbshapes result -vertex 4 -edge 3
|
||||
checknbshapes result -vertex 3 -edge 2
|
||||
|
||||
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
|
||||
|
@@ -1,21 +0,0 @@
|
||||
puts "========"
|
||||
puts "OCP-1948: Implement non-uniform scaling in Gltf Import"
|
||||
puts "========"
|
||||
Close D -silent
|
||||
ReadGltf D [locate_data_file bug_ocp1948_PSU_Cartoning_subunit__right-01.01.01.03-CART-03_green_bottom.glb]
|
||||
|
||||
XGetOneShape s D
|
||||
checknbshapes s -face 87 -compound 21
|
||||
checktrinfo s -tri 16473 -nod 15835
|
||||
|
||||
# check center of gravity
|
||||
set REF_X 18300.5
|
||||
set REF_Y -9484
|
||||
set REF_Z 129.844
|
||||
set tol 1e-4
|
||||
set pos [vprops s]
|
||||
if {([expr abs($REF_X - [lindex $pos 9])] > $tol) ||
|
||||
([expr abs($REF_Y - [lindex $pos 12])] > $tol) ||
|
||||
([expr abs($REF_Z - [lindex $pos 15])] > $tol)} {
|
||||
puts "Error: wrong position of the imported model."
|
||||
}
|
@@ -128,7 +128,6 @@ provider.GLTF.OCC.read.use.mesh.name.as.fallback : 1
|
||||
provider.GLTF.OCC.read.skip.late.data.loading : 0
|
||||
provider.GLTF.OCC.read.keep.late.data : 1
|
||||
provider.GLTF.OCC.read.print.debug.message : 0
|
||||
provider.GLTF.OCC.read.apply.scale : 1
|
||||
provider.GLTF.OCC.write.comment :
|
||||
provider.GLTF.OCC.write.author :
|
||||
provider.GLTF.OCC.write.trsf.format : 0
|
||||
|
Reference in New Issue
Block a user