1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0032086: Visualization - support deferred data loading

1) Extend Poly_Triangulation by mesh purpose, possibility to be cleared and late-load deferred data interfaces.
2) Update BRep_TFace to store list of triangulations istead of single one. And also active one. Update getter and setter of single triangulation and add new methods to interaction with whole triangulations list.
3) Update BRep_Tool to get single triangulation of face according to the input mesh purpose or whole triangulations list.
4) Update BRep_Builder to make face by not only single triangulation but whole triangulations list with specified active one.
5) Add new methods to BRepTools to interact with shape triangulations (Load/Unload/Activate/LoadAll/UnloadAllTriangulation(s))
6) Add new 'tlateload'command for shape to load/unload/activate triangulations.
7) Update 'trinfo' command by '-lods' options to print detailaed information about LODs of this shape
8) Support empty triangulations by selection. Use bounding box selection in this case.
9) Add new 'outdisplist' option to XDispaly command to print list of displayed objects to output variable but not to theDI
10) Add new '-noecho' option to vdisplay command to skip printing of displayed objects to theDI
11) Create new RWMesh_TriangulationSource as mesh data wrapper for delayed triangulation loading.
12) Create new RWMesh_TriangulationReader as base interface for reading primitive array from the buffer.
13) Cache nodes/triangles number defined in glTF file
14) Use RWMesh_TriangulationSource class as base of RWGltf_GltfLatePrimitiveArray one and RWMesh_TriangulationReader class as base of RWGltf_TriangulationReader one
15) Add possibilty to support of LODs by glTF reader. It is possible to skip data loading and load them later
16) Add new '-skiplateloading' (to skip triangulation loading), '-keeplate' (to keep information about deferred storage to load/unload triangulation later),
'-toprintdebuginfo' (to print additional debug information) options to ReadGltf command
17) Add new test of glTF late loading
This commit is contained in:
osa
2021-02-26 18:01:11 +03:00
committed by bugmaster
parent 6387996871
commit e816dce36e
46 changed files with 2475 additions and 800 deletions

View File

@@ -469,19 +469,34 @@ void BRep_Builder::MakeFace(TopoDS_Face& F,
//function : MakeFace
//purpose :
//=======================================================================
void BRep_Builder::MakeFace(TopoDS_Face& F,
const Handle(Poly_Triangulation)& T) const
void BRep_Builder::MakeFace(TopoDS_Face& theFace,
const Handle(Poly_Triangulation)& theTriangulation) const
{
Handle(BRep_TFace) TF = new BRep_TFace();
if(!F.IsNull() && F.Locked())
Handle(BRep_TFace) aTFace = new BRep_TFace();
if(!theFace.IsNull() && theFace.Locked())
{
throw TopoDS_LockedShape("BRep_Builder::MakeFace");
}
TF->Triangulation(T);
MakeShape(F, TF);
aTFace->Triangulation (theTriangulation);
MakeShape (theFace, aTFace);
}
//=======================================================================
//function : MakeFace
//purpose :
//=======================================================================
void BRep_Builder::MakeFace (TopoDS_Face& theFace,
const Poly_ListOfTriangulation& theTriangulations,
const Handle(Poly_Triangulation)& theActiveTriangulation) const
{
Handle(BRep_TFace) aTFace = new BRep_TFace();
if(!theFace.IsNull() && theFace.Locked())
{
throw TopoDS_LockedShape ("BRep_Builder::MakeFace");
}
aTFace->Triangulations (theTriangulations, theActiveTriangulation);
MakeShape (theFace, aTFace);
}
//=======================================================================
//function : MakeFace
@@ -531,20 +546,19 @@ void BRep_Builder::UpdateFace(const TopoDS_Face& F,
//function : UpdateFace
//purpose :
//=======================================================================
void BRep_Builder::UpdateFace(const TopoDS_Face& F,
const Handle(Poly_Triangulation)& T) const
void BRep_Builder::UpdateFace (const TopoDS_Face& theFace,
const Handle(Poly_Triangulation)& theTriangulation,
const Standard_Boolean theToReset) const
{
const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape());
if(TF->Locked())
const Handle(BRep_TFace)& aTFace = *((Handle(BRep_TFace)*) &theFace.TShape());
if(aTFace->Locked())
{
throw TopoDS_LockedShape("BRep_Builder::UpdateFace");
}
TF->Triangulation(T);
F.TShape()->Modified(Standard_True);
aTFace->Triangulation (theTriangulation, theToReset);
theFace.TShape()->Modified (Standard_True);
}
//=======================================================================
//function : UpdateFace
//purpose :

View File

@@ -28,7 +28,7 @@
#include <GeomAbs_Shape.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_ListOfTriangulation.hxx>
class Standard_NullObject;
class Standard_DomainError;
@@ -79,19 +79,26 @@ public:
//! Makes a Face with a surface and a location.
Standard_EXPORT void MakeFace (TopoDS_Face& F, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real Tol) const;
//! Makes a Face with a triangulation. The triangulation
//! Makes a theFace with a single triangulation. The triangulation
//! is in the same reference system than the TFace.
Standard_EXPORT void MakeFace (TopoDS_Face& F, const Handle(Poly_Triangulation)& T) const;
Standard_EXPORT void MakeFace (TopoDS_Face& theFace, const Handle(Poly_Triangulation)& theTriangulation) const;
//! Makes a Face with a list of triangulations and active one.
//! Use NULL active triangulation to set the first triangulation in list as active.
//! The triangulations is in the same reference system than the TFace.
Standard_EXPORT void MakeFace (TopoDS_Face& theFace, const Poly_ListOfTriangulation& theTriangulations, const Handle(Poly_Triangulation)& theActiveTriangulation = Handle(Poly_Triangulation)()) const;
//! Updates the face F using the tolerance value Tol,
//! surface S and location Location.
Standard_EXPORT void UpdateFace (const TopoDS_Face& F, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real Tol) const;
//! Changes a face triangulation.
//!
//! A null Triangulation removes the triangulation.
Standard_EXPORT void UpdateFace (const TopoDS_Face& F, const Handle(Poly_Triangulation)& T) const;
//! Changes a face triangulation.
//! A NULL theTriangulation removes face triangulations.
//! If theToReset is TRUE face triangulations will be reset to new list with only one input triangulation that will be active.
//! Else if theTriangulation is contained in internal triangulations list it will be made active,
//! else the active triangulation will be replaced to theTriangulation one.
Standard_EXPORT void UpdateFace (const TopoDS_Face& theFace, const Handle(Poly_Triangulation)& theTriangulation, const Standard_Boolean theToReset = true) const;
//! Updates the face Tolerance.
Standard_EXPORT void UpdateFace (const TopoDS_Face& F, const Standard_Real Tol) const;

View File

@@ -51,6 +51,131 @@ Handle(TopoDS_TShape) BRep_TFace::EmptyCopy() const
return TF;
}
//=======================================================================
//function : Triangulation
//purpose :
//=======================================================================
const Handle(Poly_Triangulation)& BRep_TFace::Triangulation (const Poly_MeshPurpose thePurpose) const
{
if (thePurpose == Poly_MeshPurpose_NONE)
{
return ActiveTriangulation();
}
for (Poly_ListOfTriangulation::Iterator anIter(myTriangulations); anIter.More(); anIter.Next())
{
const Handle(Poly_Triangulation)& aTriangulation = anIter.Value();
if ((aTriangulation->MeshPurpose() & thePurpose) != 0)
{
return aTriangulation;
}
}
if ((thePurpose & Poly_MeshPurpose_AnyFallback) != 0
&& !myTriangulations.IsEmpty())
{
// if none matching other criteria was found return the first defined triangulation
return myTriangulations.First();
}
static const Handle(Poly_Triangulation) anEmptyTriangulation;
return anEmptyTriangulation;
}
//=======================================================================
//function : Triangulation
//purpose :
//=======================================================================
void BRep_TFace::Triangulation (const Handle(Poly_Triangulation)& theTriangulation,
const Standard_Boolean theToReset)
{
if (theToReset || theTriangulation.IsNull())
{
if (!myActiveTriangulation.IsNull())
{
// Reset Active bit
myActiveTriangulation->SetMeshPurpose (myActiveTriangulation->MeshPurpose() & ~Poly_MeshPurpose_Active);
myActiveTriangulation.Nullify();
}
myTriangulations.Clear();
if (!theTriangulation.IsNull())
{
// Reset list of triangulations to new list with only one input triangulation that will be active
myTriangulations.Append (theTriangulation);
myActiveTriangulation = theTriangulation;
// Set Active bit
theTriangulation->SetMeshPurpose (theTriangulation->MeshPurpose() | Poly_MeshPurpose_Active);
}
return;
}
for (Poly_ListOfTriangulation::Iterator anIter(myTriangulations); anIter.More(); anIter.Next())
{
// Make input triangulation active if it is already contained in list of triangulations
if (anIter.Value() == theTriangulation)
{
if (!myActiveTriangulation.IsNull())
{
// Reset Active bit
myActiveTriangulation->SetMeshPurpose (myActiveTriangulation->MeshPurpose() & ~Poly_MeshPurpose_Active);
}
myActiveTriangulation = theTriangulation;
// Set Active bit
theTriangulation->SetMeshPurpose (theTriangulation->MeshPurpose() | Poly_MeshPurpose_Active);
return;
}
}
for (Poly_ListOfTriangulation::Iterator anIter(myTriangulations); anIter.More(); anIter.Next())
{
// Replace active triangulation to input one
if (anIter.Value() == myActiveTriangulation)
{
// Reset Active bit
myActiveTriangulation->SetMeshPurpose (myActiveTriangulation->MeshPurpose() & ~Poly_MeshPurpose_Active);
anIter.ChangeValue() = theTriangulation;
myActiveTriangulation = theTriangulation;
// Set Active bit
theTriangulation->SetMeshPurpose (theTriangulation->MeshPurpose() | Poly_MeshPurpose_Active);
return;
}
}
}
//=======================================================================
//function : Triangulations
//purpose :
//=======================================================================
void BRep_TFace::Triangulations (const Poly_ListOfTriangulation& theTriangulations,
const Handle(Poly_Triangulation)& theActiveTriangulation)
{
if (theTriangulations.IsEmpty())
{
myActiveTriangulation.Nullify();
myTriangulations.Clear();
return;
}
Standard_Boolean anActiveInList = false;
for (Poly_ListOfTriangulation::Iterator anIter(theTriangulations); anIter.More(); anIter.Next())
{
const Handle(Poly_Triangulation)& aTriangulation = anIter.Value();
Standard_ASSERT_RAISE (!aTriangulation.IsNull(), "Try to set list with NULL triangulation to the face");
if (aTriangulation == theActiveTriangulation)
{
anActiveInList = true;
}
// Reset Active bit
aTriangulation->SetMeshPurpose (aTriangulation->MeshPurpose() & ~Poly_MeshPurpose_Active);
}
Standard_ASSERT_RAISE (theActiveTriangulation.IsNull() || anActiveInList, "Active triangulation isn't part of triangulations list");
myTriangulations = theTriangulations;
if (theActiveTriangulation.IsNull())
{
// Save the first one as active
myActiveTriangulation = myTriangulations.First();
}
else
{
myActiveTriangulation = theActiveTriangulation;
}
myActiveTriangulation->SetMeshPurpose (myActiveTriangulation->MeshPurpose() | Poly_MeshPurpose_Active);
}
//=======================================================================
//function : DumpJson
//purpose :
@@ -61,10 +186,16 @@ void BRep_TFace::DumpJson (Standard_OStream& theOStream, Standard_Integer theDep
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TopoDS_TFace)
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myActiveTriangulation.get())
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySurface.get())
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTriangulation.get())
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myLocation)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTolerance)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNaturalRestriction)
for (Poly_ListOfTriangulation::Iterator anIter(myTriangulations); anIter.More(); anIter.Next())
{
const Handle(Poly_Triangulation)& aTriangulation = anIter.Value();
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aTriangulation.get())
}
}

View File

@@ -20,16 +20,15 @@
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Poly_ListOfTriangulation.hxx>
#include <TopLoc_Location.hxx>
#include <Standard_Real.hxx>
#include <Standard_Boolean.hxx>
#include <TopoDS_TFace.hxx>
class Geom_Surface;
class Poly_Triangulation;
class TopLoc_Location;
class TopoDS_TShape;
class BRep_TFace;
DEFINE_STANDARD_HANDLE(BRep_TFace, TopoDS_TFace)
@@ -42,8 +41,8 @@ DEFINE_STANDARD_HANDLE(BRep_TFace, TopoDS_TFace)
//! True the boundary of the face is known to be the
//! parametric space (Umin, UMax, VMin, VMax).
//!
//! * An optional Triangulation. If there is a
//! triangulation the surface can be absent.
//! * An optional list of triangulations. If there are any
//! triangulations the surface can be absent.
//!
//! The Location is used for the Surface.
//!
@@ -60,30 +59,51 @@ class BRep_TFace : public TopoDS_TFace
public:
//! Creates an empty TFace.
Standard_EXPORT BRep_TFace();
const Handle(Geom_Surface)& Surface() const;
const Handle(Poly_Triangulation)& Triangulation() const;
const TopLoc_Location& Location() const;
Standard_Real Tolerance() const;
void Surface (const Handle(Geom_Surface)& S);
void Triangulation (const Handle(Poly_Triangulation)& T);
void Location (const TopLoc_Location& L);
void Tolerance (const Standard_Real T);
Standard_Boolean NaturalRestriction() const;
void NaturalRestriction (const Standard_Boolean N);
//! Returns face surface.
const Handle(Geom_Surface)& Surface() const { return mySurface; }
//! Sets surface for this face.
void Surface (const Handle(Geom_Surface)& theSurface) { mySurface = theSurface;}
//! Returns the face location.
const TopLoc_Location& Location() const { return myLocation; }
//! Sets the location for this face.
void Location (const TopLoc_Location& theLocation) { myLocation = theLocation; }
//! Returns the face tolerance.
Standard_Real Tolerance() const { return myTolerance; }
//! Sets the tolerance for this face.
void Tolerance (const Standard_Real theTolerance) { myTolerance = theTolerance; }
//! Returns TRUE if the boundary of this face is known to be the parametric space (Umin, UMax, VMin, VMax).
Standard_Boolean NaturalRestriction() const { return myNaturalRestriction; }
//! Sets the flag that is TRUE if the boundary of this face is known to be the parametric space.
void NaturalRestriction (const Standard_Boolean theRestriction) { myNaturalRestriction = theRestriction; }
//! Returns the triangulation of this face according to the mesh purpose.
//! @param theMeshPurpose [in] a mesh purpose to find appropriate triangulation (NONE by default).
//! @return an active triangulation in case of NONE purpose,
//! the first triangulation appropriate for the input purpose,
//! just the first triangulation if none matching other criteria and input purpose is AnyFallback
//! or null handle if there is no any suitable triangulation.
Standard_EXPORT const Handle(Poly_Triangulation)& Triangulation (const Poly_MeshPurpose thePurpose = Poly_MeshPurpose_NONE) const;
//! Sets input triangulation for this face.
//! @param theTriangulation [in] triangulation to be set
//! @param theToReset [in] flag to reset triangulations list to new list with only one input triangulation.
//! If theTriangulation is NULL internal list of triangulations will be cleared and active triangulation will be nullified.
//! If theToReset is TRUE internal list of triangulations will be reset
//! to new list with only one input triangulation that will be active.
//! Else if input triangulation is contained in internal triangulations list it will be made active,
//! else the active triangulation will be replaced to input one.
Standard_EXPORT void Triangulation (const Handle(Poly_Triangulation)& theTriangulation, const Standard_Boolean theToReset = true);
//! Returns a copy of the TShape with no sub-shapes.
//! The new Face has no triangulation.
Standard_EXPORT virtual Handle(TopoDS_TShape) EmptyCopy() const Standard_OVERRIDE;
@@ -91,33 +111,35 @@ public:
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
public:
//! Returns the list of available face triangulations.
const Poly_ListOfTriangulation& Triangulations() const { return myTriangulations; }
//! Sets input list of triangulations and currently active triangulation for this face.
//! If list is empty internal list of triangulations will be cleared and active triangulation will be nullified.
//! Else this list will be saved and the input active triangulation be saved as active.
//! Use NULL active triangulation to set the first triangulation in list as active.
//! Note: the method throws exception if there is any NULL triangulation in input list or
//! if this list doesn't contain input active triangulation.
Standard_EXPORT void Triangulations (const Poly_ListOfTriangulation& theTriangulations, const Handle(Poly_Triangulation)& theActiveTriangulation);
//! Returns number of available face triangulations.
Standard_Integer NbTriangulations() const { return myTriangulations.Size(); }
//! Returns current active triangulation.
const Handle(Poly_Triangulation)& ActiveTriangulation() const { return myActiveTriangulation; }
DEFINE_STANDARD_RTTIEXT(BRep_TFace,TopoDS_TFace)
protected:
private:
Poly_ListOfTriangulation myTriangulations;
Handle(Poly_Triangulation) myActiveTriangulation;
Handle(Geom_Surface) mySurface;
Handle(Poly_Triangulation) myTriangulation;
TopLoc_Location myLocation;
Standard_Real myTolerance;
Standard_Boolean myNaturalRestriction;
};
#include <BRep_TFace.lxx>
#endif // _BRep_TFace_HeaderFile

View File

@@ -1,127 +0,0 @@
// Created on: 1992-08-25
// Created by: Modelistation
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
//=======================================================================
//function : Surface
//purpose :
//=======================================================================
inline const Handle(Geom_Surface)& BRep_TFace::Surface()const
{
return mySurface;
}
//=======================================================================
//function : Triangulation
//purpose :
//=======================================================================
inline const Handle(Poly_Triangulation)& BRep_TFace::Triangulation()const
{
return myTriangulation;
}
//=======================================================================
//function : Location
//purpose :
//=======================================================================
inline const TopLoc_Location& BRep_TFace::Location()const
{
return myLocation;
}
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
inline Standard_Real BRep_TFace::Tolerance()const
{
return myTolerance;
}
//=======================================================================
//function : Surface
//purpose :
//=======================================================================
inline void BRep_TFace::Surface(const Handle(Geom_Surface)& S)
{
mySurface = S;
}
//=======================================================================
//function : Triangulation
//purpose :
//=======================================================================
inline void BRep_TFace::Triangulation(const Handle(Poly_Triangulation)& T)
{
myTriangulation = T;
}
//=======================================================================
//function : Location
//purpose :
//=======================================================================
inline void BRep_TFace::Location(const TopLoc_Location& L)
{
myLocation = L;
}
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
inline void BRep_TFace::Tolerance(const Standard_Real T)
{
myTolerance = T;
}
//=======================================================================
//function : NaturalRestriction
//purpose :
//=======================================================================
inline Standard_Boolean BRep_TFace::NaturalRestriction()const
{
return myNaturalRestriction;
}
//=======================================================================
//function : NaturalRestriction
//purpose :
//=======================================================================
inline void BRep_TFace::NaturalRestriction(const Standard_Boolean N)
{
myNaturalRestriction = N;
}

View File

@@ -113,16 +113,27 @@ Handle(Geom_Surface) BRep_Tool::Surface(const TopoDS_Face& F)
//=======================================================================
//function : Triangulation
//purpose : Returns the Triangulation of the face. It is a
// null handle if there is no triangulation.
//purpose :
//=======================================================================
const Handle(Poly_Triangulation)& BRep_Tool::Triangulation(const TopoDS_Face& F,
TopLoc_Location& L)
const Handle(Poly_Triangulation)& BRep_Tool::Triangulation (const TopoDS_Face& theFace,
TopLoc_Location& theLocation,
const Poly_MeshPurpose theMeshPurpose)
{
L = F.Location();
const BRep_TFace* TF = static_cast<const BRep_TFace*>(F.TShape().get());
return TF->Triangulation();
theLocation = theFace.Location();
const BRep_TFace* aTFace = static_cast<const BRep_TFace*>(theFace.TShape().get());
return aTFace->Triangulation (theMeshPurpose);
}
//=======================================================================
//function : Triangulations
//purpose :
//=======================================================================
const Poly_ListOfTriangulation& BRep_Tool::Triangulations (const TopoDS_Face& theFace,
TopLoc_Location& theLocation)
{
theLocation = theFace.Location();
const BRep_TFace* aTFace = static_cast<const BRep_TFace*>(theFace.TShape().get());
return aTFace->Triangulations();
}
//=======================================================================

View File

@@ -27,7 +27,7 @@
#include <Geom2d_Curve.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_ListOfTriangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_Polygon2D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
@@ -63,11 +63,24 @@ public:
//! Returns the geometric surface of the face. It can
//! be a copy if there is a Location.
Standard_EXPORT static Handle(Geom_Surface) Surface (const TopoDS_Face& F);
//! Returns the Triangulation of the face. It is a
//! null handle if there is no triangulation.
Standard_EXPORT static const Handle(Poly_Triangulation)& Triangulation (const TopoDS_Face& F, TopLoc_Location& L);
//! Returns the triangulation of the face according to the mesh purpose.
//! @param theFace [in] the input face to find triangulation.
//! @param theLocation [out] the face location.
//! @param theMeshPurpose [in] a mesh purpose to find appropriate triangulation (NONE by default).
//! @return an active triangulation in case of NONE purpose,
//! the first triangulation appropriate for the input purpose,
//! just the first triangulation if none matching other criteria and input purpose is AnyFallback
//! or null handle if there is no any suitable triangulation.
Standard_EXPORT static const Handle(Poly_Triangulation)& Triangulation (const TopoDS_Face& theFace, TopLoc_Location& theLocation,
const Poly_MeshPurpose theMeshPurpose = Poly_MeshPurpose_NONE);
//! Returns all triangulations of the face.
//! @param theFace [in] the input face.
//! @param theLocation [out] the face location.
//! @return list of all available face triangulations.
Standard_EXPORT static const Poly_ListOfTriangulation& Triangulations (const TopoDS_Face& theFace, TopLoc_Location& theLocation);
//! Returns the tolerance of the face.
Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Face& F);

View File

@@ -47,7 +47,6 @@ BRep_TEdge.hxx
BRep_TEdge.lxx
BRep_TFace.cxx
BRep_TFace.hxx
BRep_TFace.lxx
BRep_Tool.cxx
BRep_Tool.hxx
BRep_TVertex.cxx