1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

Compare commits

..

40 Commits

Author SHA1 Message Date
vmigunov
a0c6a637fa 0023860: Bad memory access intersecting two nearly coincident cylindrical faces
Test of 2 nearly coincident cylindrical faces intersection is added
2022-08-12 12:29:03 +03:00
mzernova
81d569625e 0033084: Visualization - Cylindrical prism is selectable only by its base when extruded in some directions
Fixed bounding boxes for Select3D_SensitiveCylinder.

Added display of Select3D_SensitiveCylinder presentation using the "vsensdis" command.
Added test vselect/bugs/bug33084.
2022-08-04 17:50:46 +03:00
ngavrilo
6072d3093c 0032992: Visualization - Font_TextFormatter should wrap words when possible 2022-08-02 17:13:03 +03:00
jgv
e1b097eb67 0033006: Modelling Algorithms - UnifySameDomain raises exception
Correct processing cases where a group of faces lies on U-periodic and V-periodic (torus-like) surface.

Add comments according to the remarks
2022-07-29 19:11:52 +03:00
jgv
92d22d7d62 0033080: Wrong projection point from ShapeAnalysis_Surface
Correct Draw command "projface" so that it really finds only projection points belonging to the face.
2022-07-29 19:10:37 +03:00
dpasukhi
1b423e3287 0033068: Draw Harness, XDEDRAW - improve XGetProperties command to work with all document labels
Upgrade DRAW function XGetProperties to work with all document labels or sequence of labels
2022-07-24 22:33:24 +03:00
kgv
cb8519be19 0033074: Visualization, TKOpenGl - PBR shader compilation error on Mesa OpenGL 3.10033074
Graphic3d_ShaderManager::getPBREnvBakingProgram() - fix setting Graphic3d_ShaderProgram::SetPBR()
before defining GLSL version via defaultGlslVersion() that relies on this property.
2022-07-22 20:30:00 +03:00
kgv
617a2905a9 0033073: Coding Rules, RWGltf_CafWriter - suppress CLang warning coming from Draco library 2022-07-22 20:29:08 +03:00
kgv
18559e93cf 0033072: Configuration - ViewerTest_EventManager.cxx compilation error due to missing header on Emscripten
Added missing `#include <Message.hxx>`.
2022-07-22 20:28:01 +03:00
abulyche
c2e01cc5cc 0024049: Modeling Algorithms - crash in BRepOffsetAPI_MakePipe
Added the test for this ticket.
2022-07-22 20:27:15 +03:00
oan
0acc1ab47c 0033060: [Regression to 7.4.0] Mesh - Sub-precisional links provoke failure on face
Slightly increase exact resolution so to cover links with approximate length equal to resolution itself on sub-resolution differences.
2022-07-19 21:22:41 +03:00
ifv
b315a85dd7 0032940: Canonical Recognition: Some surfaces are not recognized as cylindrical surfaces
New method for recognizing cylindrical surfaces based on analysis Gaussian field of initial surface is added  in
class GeomConvert_SurfToAnaSurf
2022-07-19 21:20:53 +03:00
atychini
411ad1a819 0033055: Data Exchange, RWPly_Provider - remove dependency from BRepLib_PointCloudShape
Removing PointCloud writing feature from the RWPly_Provider class.
Getting rid of Pointcloud-related parameters in the RWPly_ConfigurationNode.
2022-07-18 07:32:54 +03:00
kgv
bbf49a300c 0033066: Visualization - null pointer dereference in MeshVS_ElementalColorPrsBuilder::Build() function
Added missing Boolean flag check.
2022-07-15 18:23:06 +03:00
ona
0bab2704ae 0031080: Data Exchange, STL reader - improve API for reading multi-domain STL files
reading of multidomain stl files into separate Poly_Triangulation objects
2022-07-15 18:22:10 +03:00
azv
33c8a72788 0031479: Modeling Algorithms - exception on geometry transformation of triangulation-only shapes (without geometry surface)
* Avoid crash in BRepBuilderAPI_GTransform algorithm. The crash in BRepBuilder_Transform has been solved by 0032716.
* Move copying modifier to BRepTools package.
* Implement copying of triangulation in BRepTools_NurbsConvertModification.
* Implement transformation of a triangulation in BRepTools_GTrsfModification.
* Update test case bugs/mesh/bug22778 to clean the triangulation after conversion to NURBS (reproduce the same behavior as before).
2022-07-08 19:30:13 +03:00
abulyche
315ed0be41 0032716: Modeling Algorithms - BRepBuilderAPI_Transform discards triangulation
* Implement methods for copying tessellation to BRepTools_TrsfModification to keep the triangulation during transformation.
* Add tests to reproduce the problem.
2022-07-08 19:30:13 +03:00
azv
d74b1e9dd3 0033049: Command 'tclean -geom' does not remove all geometric objects from the shape
Remove unused P-curves when cleaning the geometry
2022-07-08 19:30:12 +03:00
ifv
b47b075ac5 0032995: Modeling algorithms - Interface for checking canonical geometry
GeomConvert_CurveToAnaCurve, GeomConvert_SurfToAnaSurf - geometrical algorithms
for converting geometrical curve and surfaces in canonical geometry with given tolerance.

ShapeAnalysis_CanonicalRecognition - interface for checking canonical geometry.
2022-07-08 19:26:37 +03:00
kgv
7a52478f16 0032952: Coding Rules, Graphic3d_DisplayPriority - rename inconsistent Below2/Above1 enties
Below/Below2/Below3 triplet has been renamed to Below/Below1/Below2
for consistency with Above/Above1/Above2
2022-07-07 19:28:28 +03:00
kgv
9db675b3d6 0033056: Visualization - add front face culling option
Added Graphic3d_TypeOfBackfacingModel_FrontCulled enumeration value.
OpenGl_Context::SetFaceCulling() now supports GL_FRONT in addition to GL_BACK.

Added -faceCulling option to vaspects Draw command.
2022-07-07 19:27:17 +03:00
aml
e1d576bf31 0033046: Modeling algorithms - improve performance of per-facet shape construction
Add new class (BRepBuilderAPI_MakeShapeOnMesh) to reconstruct shape from triangulation on per-facet basis.
2022-07-07 19:26:22 +03:00
ifv
e1f7382910 0028243: Bad result of the canonical recognition
LProp/LProp_CLProps.gxx - minor modification to avoid floating overflow because of multiplication of large values
2022-07-07 19:23:55 +03:00
kgv
dee5eb82b5 0033054: Configuration - link errors due to missing references to new TKXDE toolkit
src/OS/DataExchange.tcl - added missing new toolkits.
TKRWMesh - added missing reference to TKTopAlgo (for using BRepLib_PointCloudShape).
Removed redundant dependency from TKBinXCAF.
DRAWEXE - added missing references for a static build.

THE_CONFIGURATION_SCOPE definition has been corrected to postpoine calling constructor till the first variable usage.
Fixed compiler warning at SelectMgr_Frustum<3>::DumpJson() due to misleading Standard_EXPORT for an inline template method definition.
2022-07-07 19:23:00 +03:00
aml
c2eed2a326 0033048: Foundation Classes - math_ComputeKronrodPointsAndWeights indexation goes beyond the limit
Add test and explanatory comment.
2022-07-06 19:16:55 +03:00
ichesnok
3a2ca49b6d 0032867: Data Exchange - Implement Draco compression for writing glTF
Draco compression added in RWGltf_CafWriter class.
2022-07-06 19:15:56 +03:00
dpasukhi
4f53e7b37c 0033011: Data Exchange - Backward compatibility XBF format
Fixed problem with moving the attribute position.
Made the same positions as version 7.5 with adding to the end.
2022-07-04 18:58:05 +03:00
ona
e01ce0cd52 0029854: XCAF GD&T: Clear contents of reserved labels only
Clear attributes from reserved child labels only
2022-06-30 19:33:37 +03:00
ona
34c407eb34 0029415: Data Exchange - Step reader cannot read the surfaces of the main body of the shape
Test for model reading check is added
2022-06-30 19:33:37 +03:00
aml
ef4e5e3bf1 0033040: Coding - get rid of unused headers [Storage to TopOpeBRepTool] 2022-06-30 19:33:36 +03:00
mgerus
ca1491f88b 0030398: Modeling Algorithms - thrusection produces twisted solid
Change FirstBary to PrevBary to correct Offset calculation relative prev wire instead of first wire
2022-06-30 19:33:35 +03:00
akaftasev
b284dc42dc 0032446: BRepOffsetAPI_MakePipeShell crash when using -DT mode and DT_ShapeDivide on the spine
Added test case
2022-06-30 19:33:35 +03:00
akaftasev
a0ffd4a521 0032445: BRepOffsetAPI_MakePipeShell crash when using -DT mode and DT_ShapeDivide on the spine
Added test case
2022-06-30 19:33:35 +03:00
jgv
07e803dee1 0032999: Modeling Algorithms - New option in ShapeUpgrade_ShapeDivide algorithm: splitting into N parts, into N*M parts
1. Multiple changes in ShapeUpgrade_ShapeDivideArea, ShapeUpgrade_FaceDivide, ShapeUpgrade_FaceDivideArea, ShapeUpgrade_SplitSurface, ShapeUpgrade_SplitSurfaceArea: new methods NbParts and SetSplittingByNumber, changes in ShapeUpgrade_FaceDivideArea::Perform and ShapeUpgrade_SplitSurfaceArea::Compute concerning new modes of splitting.
2. New Draw command "DT_SplitByNumber" for testing new modes of splitting.
3. New subgroups "split_number" and "split_two_numbers" in the group of tests "heal" for testing new modes of splitting.
2022-06-30 19:33:34 +03:00
aml
ec2d883e53 0033041: Coding - get rid of unused headers [TopTools to Xw] 2022-06-30 19:33:34 +03:00
oan
1593d38b13 0032692: Mesh - In BRepMesh_ModelPreProcessor avoid crashes with problematic topology
Improved the processing for the case where Failure flag for the meshing face is set. Specific tests added.
Check triangulation consistency even for shapes with problematic topology given that they are suitable for keeping it.
2022-06-29 21:32:45 +03:00
atychini
aaa03c1efb 0033029: Warning on Windows 32 and 64 with VC14 after the integration of ticket 32821
Warning has been fixed by adding condition.
2022-06-29 21:32:45 +03:00
aml
b2bce1d928 0033039: Coding - get rid of unused headers [StepData to StlAPI] 2022-06-28 20:23:23 +03:00
azv
581016faeb 0033028: Standard_ConstructionError while using ShapeUpgrade_UnifySameDomain
Additional check if the sequence of circular edges is a closed chain.
2022-06-28 20:22:28 +03:00
aml
6bf38f219b 0033025: Coding - get rid of unused Standard_TooManyUsers class 2022-06-27 07:02:50 +03:00
2041 changed files with 9919 additions and 5532 deletions

View File

@@ -1,4 +1,96 @@
# Draco - a library for a lossy vertex data compression, used as extension to glTF format.
# https://github.com/google/draco
THIRDPARTY_PRODUCT("DRACO" "draco/compression/decode.h" "CSF_Draco" "")
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
if (NOT DEFINED INSTALL_DRACO)
set (INSTALL_DRACO OFF CACHE BOOL "${INSTALL_DRACO_DESCR}")
endif()
if (NOT DEFINED 3RDPARTY_DRACO_DIR)
set (3RDPARTY_DRACO_DIR "" CACHE PATH "The directory containing Draco")
endif()
if (NOT DEFINED 3RDPARTY_DRACO_INCLUDE_DIR)
set (3RDPARTY_DRACO_INCLUDE_DIR "" CACHE PATH "The directory containing headers of the Draco")
endif()
if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY OR NOT 3RDPARTY_DRACO_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY_DIR}")
set (3RDPARTY_DRACO_LIBRARY "" CACHE FILEPATH "Draco library" FORCE)
endif()
if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY_DIR)
set (3RDPARTY_DRACO_LIBRARY_DIR "" CACHE PATH "The directory containing Draco library")
endif()
if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}")
if (NOT 3RDPARTY_DRACO_DIR OR NOT EXISTS "${3RDPARTY_DRACO_DIR}")
FIND_PRODUCT_DIR("${3RDPARTY_DIR}" draco DRACO_DIR_NAME)
if (DRACO_DIR_NAME)
set (3RDPARTY_DRACO_DIR "${3RDPARTY_DIR}/${DRACO_DIR_NAME}" CACHE PATH "The directory containing Draco" FORCE)
endif()
endif()
endif()
if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}")
set (DRACO_INCLUDE_PATH "${3RDPARTY_DRACO_DIR}/include")
set (DRACO_LIBRARY_PATH "${3RDPARTY_DRACO_DIR}/lib")
endif()
if (NOT 3RDPARTY_DRACO_INCLUDE_DIR)
if (DRACO_INCLUDE_PATH AND EXISTS "${DRACO_INCLUDE_PATH}")
set (3RDPARTY_DRACO_INCLUDE_DIR "${DRACO_INCLUDE_PATH}" CACHE FILEPATH "The directory containing headers of DRACO" FORCE)
endif()
endif()
if (NOT 3RDPARTY_DRACO_LIBRARY_DIR)
if (DRACO_LIBRARY_PATH AND EXISTS "${DRACO_LIBRARY_PATH}")
set (3RDPARTY_DRACO_LIBRARY_DIR "${DRACO_LIBRARY_PATH}" CACHE FILEPATH "The directory containing DRACO library" FORCE)
endif()
endif()
if (3RDPARTY_DRACO_INCLUDE_DIR AND EXISTS "${3RDPARTY_DRACO_INCLUDE_DIR}")
list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_DRACO_INCLUDE_DIR}")
else()
list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_DRACO_INCLUDE_DIR)
endif()
if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}")
if (NOT 3RDPARTY_DRACO_LIBRARY OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY}")
set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib .a)
set (3RDPARTY_DRACO_LIBRARY "3RDPARTY_DRACO_LIBRARY-NOTFOUND" CACHE FILEPATH "The path to Draco library" FORCE)
find_library (3RDPARTY_DRACO_LIBRARY NAMES ${CSF_Draco}
PATHS "${3RDPARTY_DRACO_LIBRARY_DIR}"
PATH_SUFFIXES lib
CMAKE_FIND_ROOT_PATH_BOTH
NO_DEFAULT_PATH)
if (3RDPARTY_DRACO_LIBRARY AND EXISTS "${3RDPARTY_DRACO_LIBRARY}")
get_filename_component (3RDPARTY_DRACO_LIBRARY_DIR "${3RDPARTY_DRACO_LIBRARY}" PATH)
set (3RDPARTY_DRACO_LIBRARY_DIR "${3RDPARTY_DRACO_LIBRARY_DIR}" CACHE FILEPATH "The directory containing Draco library" FORCE)
endif()
endif()
endif()
if (3RDPARTY_DRACO_LIBRARY_DIR AND EXISTS "${3RDPARTY_DRACO_LIBRARY_DIR}")
list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_DRACO_LIBRARY_DIR}")
else()
list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_DRACO_LIBRARY_DIR)
endif()
if (INSTALL_DRACO)
get_filename_component(3RDPARTY_DRACO_LIBRARY_REALPATH ${3RDPARTY_DRACO_LIBRARY} REALPATH)
if (SINGLE_GENERATOR)
install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} DESTINATION "${INSTALL_DIR_LIB}")
else()
install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH}
CONFIGURATIONS Release
DESTINATION "${INSTALL_DIR_LIB}")
install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH}
CONFIGURATIONS RelWithDebInfo
DESTINATION "${INSTALL_DIR_LIB}i")
install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH}
CONFIGURATIONS Debug
DESTINATION "${INSTALL_DIR_LIB}d")
endif()
endif()

View File

@@ -338,7 +338,8 @@ The <i>GeomConvert</i> package also provides the following:
* a splitting algorithm, which determines the curves along which a BSpline surface should be cut in order to obtain patches with the same degree of continuity,
* global functions to construct BSpline surfaces created by this splitting algorithm, or by other types of BSpline surface segmentation,
* an algorithm, which converts a BSpline surface into a series of adjacent Bezier surfaces,
* an algorithm, which converts a grid of adjacent Bezier surfaces into a BSpline surface.
* an algorithm, which converts a grid of adjacent Bezier surfaces into a BSpline surface.
* algorithms that converts NURBS, Bezier and other general parametrized curves and surface into anaytical curves and surfaces.
@subsection occt_modat_1_4 Points on Curves

View File

@@ -1007,6 +1007,25 @@ Standard_Integer aNbOffsetSurfaces = aCheckContents.NbOffsetSurf();
Handle(TopTools_HSequenceOfShape) aSeqFaces = aCheckContents.OffsetSurfaceSec();
~~~~
@subsubsection occt_shg_3_2_4 Analysis of shape underlined geometry
Class *ShapeAnalysis_CanonicalRecognition* provides tools that analyze geometry of shape and explore the possibility of converting geometry into a canonical form.
Canonical forms for curves are lines, circles and ellipses.
Canonical forms for surfaces are planar, cylindrical, conical and spherical surfaces.
Recognition and converting into canonical form is performed according to maximal deviation criterium: maximal distance between initial and canonical geometrical objects must be less, than given value.
Analysis of curves is allowed for following shapes:
* edge - algorithm checks 3d curve of edge
* wire - algorithm checks 3d curves of all edges in order to convert them in the same analytical curve
Analysis of surfaces is allowed for following shapes:
* face - algorithm checks surface of face
* shell - algorithm checks surfaces of all faces in order to convert them in the same analytical surface
* edge - algorithm checks all surfaces that are shared by given edge in order convert one of them in analytical surface, which most close to the input sample surface.
* wire - the same as for edge, but algorithm checks all edges of wire in order to find analytical surface, which most close to the input sample surface.
@section occt_shg_4 Upgrading
Upgrading tools are intended for adaptation of shapes for better use by Open CASCADE Technology or for customization to particular needs, i.e. for export to another system.

View File

@@ -1948,7 +1948,7 @@ int mcrcomm_(integer *kop,
/* Local variables */
intptr_t ideb;
doublereal dtab[32000];
intptr_t itab[160] = {0} /* was [4][40] */;
intptr_t itab[160] /* was [4][40] */;
intptr_t ipre;
integer i__, j, k;
@@ -2522,7 +2522,7 @@ int AdvApp2Var_SysBase::mcrlist_(integer *ier) const
/* Local variables */
char cfmt[1];
doublereal dfmt = 0.0; // unused
doublereal dfmt;
integer ifmt, i__, nufmt, ntotal;
char subrou[7];
@@ -2667,7 +2667,7 @@ int AdvApp2Var_SysBase::mcrrqst_(integer *iunit,
integer i__1, i__2;
/* Local variables */
doublereal dfmt = 0.0; // unused
doublereal dfmt;
integer ifmt, iver;
char subr[7];
integer ksys , ibyte, irest, ier;

View File

@@ -77,8 +77,7 @@ static void ComputeTrsf2d(const Handle(TheWLine)& theline,
for(Standard_Integer i=1; i<=aNbPnts; i++)
{
const IntSurf_PntOn2S POn2S = theline->Point(i);
Standard_Real U = 0.0;
Standard_Real V = 0.0;
Standard_Real U,V;
(POn2S.*pfunc)(U,V);
aUmin = Min(U, aUmin);
aVmin = Min(V, aVmin);

View File

@@ -103,7 +103,7 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c
"-na - disables the approximation of the section curves.\n",
__FILE__, bsection, g);
//
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2] "
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2] [-noapprox] "
"[-p u1 v1 u2 v2 (to add start points] [-v (for extended output)]",
__FILE__, bopcurves, g);
theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-c] [-ni] [-ai]",
@@ -544,7 +544,7 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
const char** a)
{
if (n<3) {
di << "Usage: bopcurves F1 F2 [-2d/-2d1/-2d2] "
di << "Usage: bopcurves F1 F2 [-2d/-2d1/-2d2] [-noapprox] "
"[-p u1 v1 u2 v2 (to add start points] [-v (for extended output)]\n";
return 1;
}
@@ -597,6 +597,9 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
else if (!strcasecmp(a[i],"-2d2")) {
aToApproxC2dOnS2 = Standard_True;
}
else if (!strcasecmp(a[i],"-noapprox")) {
aToApproxC3d = Standard_False;
}
else if (!strcasecmp(a[i],"-p")) {
IntSurf_PntOn2S aPt;
const Standard_Real aU1 = Draw::Atof(a[++i]);

View File

@@ -15,186 +15,8 @@
// commercial license or contractual agreement.
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepTools_Modification.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <Poly_Triangulation.hxx>
namespace {
//! Tool class implementing necessary functionality for copying geometry
class BRepBuilderAPI_Copy_Modification : public BRepTools_Modification
{
public:
BRepBuilderAPI_Copy_Modification (const Standard_Boolean copyGeom,
const Standard_Boolean copyMesh)
: myCopyGeom(copyGeom),
myCopyMesh(copyMesh)
{
}
//! Returns true to indicate the need to copy face;
//! copies surface if requested
Standard_Boolean NewSurface (const TopoDS_Face& F, Handle(Geom_Surface)& S,
TopLoc_Location& L, Standard_Real& Tol,
Standard_Boolean& RevWires, Standard_Boolean& RevFace) Standard_OVERRIDE
{
S = BRep_Tool::Surface(F,L);
Tol = BRep_Tool::Tolerance(F);
RevWires = RevFace = Standard_False;
if ( ! S.IsNull() && myCopyGeom )
S = Handle(Geom_Surface)::DownCast(S->Copy());
return Standard_True;
}
//! Returns true to indicate the need to copy triangulation;
//! copies it if required
Standard_Boolean NewTriangulation(const TopoDS_Face& F, Handle(Poly_Triangulation)& T) Standard_OVERRIDE
{
if (!myCopyMesh
&& BRep_Tool::IsGeometric (F))
{
return Standard_False;
}
TopLoc_Location L;
T = BRep_Tool::Triangulation(F, L);
if (T.IsNull())
return Standard_False;
// mesh is copied if and only if the geometry need to be copied too
if (myCopyGeom)
T = T->Copy();
return Standard_True;
}
//! Returns true to indicate the need to copy edge;
//! copies curves if requested
Standard_Boolean NewCurve (const TopoDS_Edge& E, Handle(Geom_Curve)& C,
TopLoc_Location& L, Standard_Real& Tol) Standard_OVERRIDE
{
Standard_Real f,l;
C = BRep_Tool::Curve (E, L, f, l);
Tol = BRep_Tool::Tolerance(E);
if ( ! C.IsNull() && myCopyGeom )
C = Handle(Geom_Curve)::DownCast(C->Copy());
return Standard_True;
}
//! Returns true to indicate the need to copy polygon;
//! copies it if required
Standard_Boolean NewPolygon(const TopoDS_Edge& E, Handle(Poly_Polygon3D)& P) Standard_OVERRIDE
{
if (!myCopyMesh
&& BRep_Tool::IsGeometric (E))
{
return Standard_False;
}
TopLoc_Location aLoc;
P = BRep_Tool::Polygon3D(E, aLoc);
if (P.IsNull())
return Standard_False;
// polygon is copied if and only if the geometry need to be copied too
if (myCopyGeom)
P = P->Copy();
return Standard_True;
}
//! Returns true to indicate the need to copy polygon;
//! copies it if required
Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& E, const TopoDS_Face& F,
Handle(Poly_PolygonOnTriangulation)& P) Standard_OVERRIDE
{
if (!myCopyMesh
&& BRep_Tool::IsGeometric (E))
{
return Standard_False;
}
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aTria = BRep_Tool::Triangulation(F, aLoc);
P = BRep_Tool::PolygonOnTriangulation(E, aTria, aLoc);
if (P.IsNull())
return Standard_False;
// polygon is copied if and only if the geometry need to be copied too
if (myCopyGeom)
P = P->Copy();
return Standard_True;
}
//! Returns true to indicate the need to copy vertex
Standard_Boolean NewPoint (const TopoDS_Vertex& V, gp_Pnt& P,
Standard_Real& Tol) Standard_OVERRIDE
{
P = BRep_Tool::Pnt(V);
Tol = BRep_Tool::Tolerance(V);
return Standard_True;
}
//! Returns true to indicate the need to copy edge;
//! copies pcurve if requested
Standard_Boolean NewCurve2d (const TopoDS_Edge& E,
const TopoDS_Face& F,
const TopoDS_Edge& /*NewE*/,
const TopoDS_Face& /*NewF*/,
Handle(Geom2d_Curve)& C,
Standard_Real& Tol) Standard_OVERRIDE
{
Tol = BRep_Tool::Tolerance(E);
Standard_Real f, l;
C = BRep_Tool::CurveOnSurface (E, F, f, l);
if ( ! C.IsNull() && myCopyGeom )
C = Handle(Geom2d_Curve)::DownCast (C->Copy());
return Standard_True;
}
//! Returns true to indicate the need to copy vertex
Standard_Boolean NewParameter (const TopoDS_Vertex& V, const TopoDS_Edge& E,
Standard_Real& P, Standard_Real& Tol) Standard_OVERRIDE
{
if (V.IsNull()) return Standard_False; // infinite edge may have Null vertex
Tol = BRep_Tool::Tolerance(V);
P = BRep_Tool::Parameter (V, E);
return Standard_True;
}
//! Returns the continuity of E between F1 and F2
GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1,
const TopoDS_Face& F2, const TopoDS_Edge&,
const TopoDS_Face&, const TopoDS_Face&) Standard_OVERRIDE
{
return BRep_Tool::Continuity (E, F1, F2);
}
public:
DEFINE_STANDARD_RTTI_INLINE(BRepBuilderAPI_Copy_Modification,BRepTools_Modification)
private:
Standard_Boolean myCopyGeom;
Standard_Boolean myCopyMesh;
};
} // anonymous namespace
#include <BRepTools_CopyModification.hxx>
//=======================================================================
//function : BRepBuilderAPI_Copy
@@ -203,7 +25,7 @@ private:
BRepBuilderAPI_Copy::BRepBuilderAPI_Copy ()
{
myModification = new BRepBuilderAPI_Copy_Modification(Standard_True, Standard_False);
myModification = new BRepTools_CopyModification(Standard_True, Standard_False);
}
@@ -214,7 +36,7 @@ BRepBuilderAPI_Copy::BRepBuilderAPI_Copy ()
BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_Boolean copyGeom, const Standard_Boolean copyMesh)
{
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom, copyMesh);
myModification = new BRepTools_CopyModification(copyGeom, copyMesh);
DoModif(S);
}
@@ -226,7 +48,7 @@ BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_B
void BRepBuilderAPI_Copy::Perform(const TopoDS_Shape& S, const Standard_Boolean copyGeom, const Standard_Boolean copyMesh)
{
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom, copyMesh);
myModification = new BRepTools_CopyModification(copyGeom, copyMesh);
NotDone(); // on force la copie si on vient deja d`en faire une
DoModif(S);
}

View File

@@ -0,0 +1,247 @@
// Created on: 2022-06-30
// Created by: Alexander MALYSHEV
// Copyright (c) 2022-2022 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 <BRepBuilderAPI_MakeShapeOnMesh.hxx>
#include <BRep_Builder.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <NCollection_IndexedDataMap.hxx>
namespace
{
//! Structure representing mesh edge.
struct Edge
{
//! Constructor. Sets edge nodes.
Edge(const Standard_Integer TheIdx1,
const Standard_Integer TheIdx2)
: Idx1(Min(TheIdx1, TheIdx2)),
Idx2(Max(TheIdx1, TheIdx2))
{}
//! Comparison operator.
Standard_Boolean operator<(const Edge& other) const
{
if (Idx1 < other.Idx1 ||
(Idx1 == other.Idx1 && Idx2 < other.Idx2))
{
return Standard_True;
}
return Standard_False;
}
//! First index. It is lower or equal than the second.
Standard_Integer Idx1;
//! Second index.
Standard_Integer Idx2;
};
//! Hasher of Edge structure.
struct EdgeHasher
{
//! Returns hash code for the given edge.
static Standard_Integer HashCode(const Edge& theEdge,
const Standard_Integer theUpperBound)
{
// Circle-based collisions.
return ::HashCode(theEdge.Idx1 * theEdge.Idx1 + theEdge.Idx2 * theEdge.Idx2, theUpperBound);
}
//! Returns true if two edges are equal.
static Standard_Boolean IsEqual(const Edge& theEdge1,
const Edge& theEdge2)
{
return theEdge1.Idx1 == theEdge2.Idx1 && theEdge1.Idx2 == theEdge2.Idx2;
}
};
}
//=======================================================================
//function : Build
//purpose :
//=======================================================================
void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange)
{
// Generally, this method guarantees topology sharing by mapping mesh primitives
// into topological counterparts.
// mesh points -> topological vertices
// mesh edges -> topological edges
// Cannot reconstruct anything from null or empty mesh.
if (myMesh.IsNull() || myMesh->NbNodes() == 0 || myMesh->NbTriangles() == 0)
return;
const Standard_Integer aNbNodes = myMesh->NbNodes();
const Standard_Integer aNbTriangles = myMesh->NbTriangles();
// We are going to have three loops: iterate once over nodes and iterate twice
// over triangles of input mesh.
Message_ProgressScope aPS(theRange,
"Per-facet shape construction",
Standard_Real(aNbNodes + 2 * aNbTriangles));
// Build shared vertices.
NCollection_IndexedDataMap<Standard_Integer, TopoDS_Vertex> aPnt2VertexMap;
for (Standard_Integer i = 1; i <= aNbNodes; ++i)
{
aPS.Next();
if (aPS.UserBreak())
return;
const gp_Pnt aP = myMesh->Node(i);
const TopoDS_Vertex aV = BRepBuilderAPI_MakeVertex(aP);
aPnt2VertexMap.Add(i, aV);
}
// Build shared edges.
NCollection_IndexedDataMap<Edge, TopoDS_Edge, EdgeHasher> anEdgeToTEgeMap;
for (Standard_Integer i = 1; i <= aNbTriangles; ++i)
{
aPS.Next();
if (aPS.UserBreak())
return;
Standard_Integer anIdx[3];
const Poly_Triangle& aTriangle = myMesh->Triangle(i);
aTriangle.Get(anIdx[0], anIdx[1], anIdx[2]);
// Skip degenerated triangles.
if (anIdx[0] == anIdx[1] || anIdx[0] == anIdx[2] || anIdx[1] == anIdx[2])
continue;
const gp_Pnt aP1 = myMesh->Node(anIdx[0]);
const gp_Pnt aP2 = myMesh->Node(anIdx[1]);
const gp_Pnt aP3 = myMesh->Node(anIdx[2]);
const Standard_Real aD1 = aP1.SquareDistance(aP2);
const Standard_Real aD2 = aP1.SquareDistance(aP3);
const Standard_Real aD3 = aP2.SquareDistance(aP3);
if (aD1 < gp::Resolution() ||
aD2 < gp::Resolution() ||
aD3 < gp::Resolution())
{
continue;
}
// Edges are constructed in forward order for the existing normals orientation.
// In Poly_Triangulation, positive direction is defined as cross product:
// (aV1, aV2) x (aV1, aV3).
const TopoDS_Vertex& aV1 = aPnt2VertexMap.FindFromKey(anIdx[0]);
const TopoDS_Vertex& aV2 = aPnt2VertexMap.FindFromKey(anIdx[1]);
const TopoDS_Vertex& aV3 = aPnt2VertexMap.FindFromKey(anIdx[2]);
const Edge aMeshEdge1(anIdx[0], anIdx[1]);
const Edge aMeshEdge2(anIdx[1], anIdx[2]);
const Edge aMeshEdge3(anIdx[2], anIdx[0]);
BRepBuilderAPI_MakeEdge aMaker1(aV1, aV2);
BRepBuilderAPI_MakeEdge aMaker2(aV2, aV3);
BRepBuilderAPI_MakeEdge aMaker3(aV3, aV1);
TopoDS_Edge aTE1 = aMaker1.Edge();
if (anIdx[1] < anIdx[0])
aTE1.Reverse();
TopoDS_Edge aTE2 = aMaker2.Edge();
if (anIdx[2] < anIdx[1])
aTE2.Reverse();
TopoDS_Edge aTE3 = aMaker3.Edge();
if (anIdx[0] < anIdx[2])
aTE3.Reverse();
anEdgeToTEgeMap.Add(aMeshEdge1, aTE1);
anEdgeToTEgeMap.Add(aMeshEdge2, aTE2);
anEdgeToTEgeMap.Add(aMeshEdge3, aTE3);
}
// Construct planar faces using shared topology.
TopoDS_Compound aResult;
BRep_Builder aBB;
aBB.MakeCompound(aResult);
for (Standard_Integer i = 1; i <= aNbTriangles; ++i)
{
aPS.Next();
if (aPS.UserBreak())
return;
Standard_Integer anIdx[3];
const Poly_Triangle& aTriangle = myMesh->Triangle(i);
aTriangle.Get(anIdx[0], anIdx[1], anIdx[2]);
const Edge aMeshEdge1(anIdx[0], anIdx[1]);
const Edge aMeshEdge2(anIdx[1], anIdx[2]);
const Edge aMeshEdge3(anIdx[2], anIdx[0]);
const Standard_Boolean isReversed1 = anIdx[1] < anIdx[0];
const Standard_Boolean isReversed2 = anIdx[2] < anIdx[1];
const Standard_Boolean isReversed3 = anIdx[0] < anIdx[2];
// Edges can be skipped in case of mesh defects - topologically or geometrically
// degenerated triangles.
const Standard_Boolean aHasAllEdges = anEdgeToTEgeMap.Contains(aMeshEdge1) &&
anEdgeToTEgeMap.Contains(aMeshEdge2) &&
anEdgeToTEgeMap.Contains(aMeshEdge3) ;
if (!aHasAllEdges)
continue;
TopoDS_Edge aTEdge1 = anEdgeToTEgeMap.FindFromKey(aMeshEdge1);
if (isReversed1)
aTEdge1.Reverse();
TopoDS_Edge aTEdge2 = anEdgeToTEgeMap.FindFromKey(aMeshEdge2);
if (isReversed2)
aTEdge2.Reverse();
TopoDS_Edge aTEdge3 = anEdgeToTEgeMap.FindFromKey(aMeshEdge3);
if (isReversed3)
aTEdge3.Reverse();
BRepBuilderAPI_MakeWire aWireMaker;
aWireMaker.Add(aTEdge1);
aWireMaker.Add(aTEdge2);
aWireMaker.Add(aTEdge3);
const TopoDS_Wire aWire = aWireMaker.Wire();
// Construct plane explicitly since it is faster than automatic construction
// within BRepBuilderAPI_MakeFace.
BRepAdaptor_Curve aC1(aTEdge1);
BRepAdaptor_Curve aC2(aTEdge2);
const gp_Dir aD1 = aC1.Line().Direction();
const gp_Dir aD2 = aC2.Line().Direction();
gp_XYZ aN = aD1.XYZ().Crossed(aD2.XYZ());
if (aN.SquareModulus() < Precision::SquareConfusion())
continue;
if (aTEdge1.Orientation() == TopAbs_REVERSED)
aN.Reverse();
if (aTEdge2.Orientation() == TopAbs_REVERSED)
aN.Reverse();
const gp_Dir aNorm(aN);
gp_Pln aPln(myMesh->Node(anIdx[0]), aNorm);
BRepBuilderAPI_MakeFace aFaceMaker(aPln, aWire);
const TopoDS_Face aFace = aFaceMaker.Face();
aBB.Add(aResult, aFace);
}
this->Done();
myShape = aResult;
}

View File

@@ -0,0 +1,46 @@
// Created on: 2022-06-30
// Created by: Alexander MALYSHEV
// Copyright (c) 2022-2022 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.
#ifndef _BRepBuilderAPI_MakeShapeOnMesh_HeaderFile
#define _BRepBuilderAPI_MakeShapeOnMesh_HeaderFile
#include <BRepBuilderAPI_MakeShape.hxx>
#include <Poly_Triangulation.hxx>
//! Builds shape on per-facet basis on the input mesh. Resulting shape has shared
//! edges by construction, but no maximization (unify same domain) is applied.
//! No generation history is provided.
class BRepBuilderAPI_MakeShapeOnMesh : public BRepBuilderAPI_MakeShape
{
public:
DEFINE_STANDARD_ALLOC
//! Ctor. Sets mesh to process.
//! @param theMesh [in] - Mesh to construct shape for.
BRepBuilderAPI_MakeShapeOnMesh(const Handle(Poly_Triangulation)& theMesh)
: myMesh(theMesh)
{}
//! Builds shape on mesh.
Standard_EXPORT virtual void Build(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
private:
Handle(Poly_Triangulation) myMesh;
};
#endif // _BRepBuilderAPI_MakeShapeOnMesh_HeaderFile

View File

@@ -36,13 +36,14 @@ BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const gp_Trsf& T) :
//purpose :
//=======================================================================
BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& S,
const gp_Trsf& T,
const Standard_Boolean Copy) :
myTrsf(T)
BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& theShape,
const gp_Trsf& theTrsf,
const Standard_Boolean theCopyGeom,
const Standard_Boolean theCopyMesh)
: myTrsf(theTrsf)
{
myModification = new BRepTools_TrsfModification(T);
Perform(S,Copy);
myModification = new BRepTools_TrsfModification(theTrsf);
Perform(theShape, theCopyGeom, theCopyMesh);
}
@@ -52,19 +53,21 @@ BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& S,
//purpose :
//=======================================================================
void BRepBuilderAPI_Transform::Perform(const TopoDS_Shape& S,
const Standard_Boolean Copy)
void BRepBuilderAPI_Transform::Perform(const TopoDS_Shape& theShape,
const Standard_Boolean theCopyGeom,
const Standard_Boolean theCopyMesh)
{
myUseModif = Copy || myTrsf.IsNegative() || (Abs(Abs(myTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
myUseModif = theCopyGeom || myTrsf.IsNegative() || (Abs(Abs(myTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
if (myUseModif) {
Handle(BRepTools_TrsfModification) theModif =
Handle(BRepTools_TrsfModification)::DownCast(myModification);
theModif->Trsf() = myTrsf;
DoModif(S,myModification);
theModif->IsCopyMesh() = theCopyMesh;
DoModif(theShape, myModification);
}
else {
myLocation = myTrsf;
myShape = S.Moved(myLocation);
myShape = theShape.Moved(myLocation);
Done();
}

View File

@@ -50,28 +50,37 @@ public:
//! to define the shape to transform.
Standard_EXPORT BRepBuilderAPI_Transform(const gp_Trsf& T);
//! Creates a transformation from the gp_Trsf <T>, and
//! applies it to the shape <S>. If the transformation
//! Creates a transformation from the gp_Trsf <theTrsf>, and
//! applies it to the shape <theShape>. If the transformation
//! is direct and isometric (determinant = 1) and
//! <Copy> = Standard_False, the resulting shape is
//! <S> on which a new location has been set.
//! <theCopyGeom> = Standard_False, the resulting shape is
//! <theShape> on which a new location has been set.
//! Otherwise, the transformation is applied on a
//! duplication of <S>.
Standard_EXPORT BRepBuilderAPI_Transform(const TopoDS_Shape& S, const gp_Trsf& T, const Standard_Boolean Copy = Standard_False);
//! duplication of <theShape>.
//! If <theCopyMesh> is true, the triangulation will be copied,
//! and the copy will be assigned to the result shape.
Standard_EXPORT BRepBuilderAPI_Transform(const TopoDS_Shape& theShape,
const gp_Trsf& theTrsf,
const Standard_Boolean theCopyGeom = Standard_False,
const Standard_Boolean theCopyMesh = Standard_False);
//! pplies the geometric transformation defined at the
//! Applies the geometric transformation defined at the
//! time of construction of this framework to the shape S.
//! - If the transformation T is direct and isometric, in
//! other words, if the determinant of the vectorial part
//! of T is equal to 1., and if Copy equals false (the
//! of T is equal to 1., and if theCopyGeom equals false (the
//! default value), the resulting shape is the same as
//! the original but with a new location assigned to it.
//! - In all other cases, the transformation is applied to a duplicate of S.
//! - In all other cases, the transformation is applied to a duplicate of theShape.
//! - If theCopyMesh is true, the triangulation will be copied,
//! and the copy will be assigned to the result shape.
//! Use the function Shape to access the result.
//! Note: this framework can be reused to apply the same
//! geometric transformation to other shapes. You only
//! need to specify them by calling the function Perform again.
Standard_EXPORT void Perform (const TopoDS_Shape& S, const Standard_Boolean Copy = Standard_False);
Standard_EXPORT void Perform (const TopoDS_Shape& theShape,
const Standard_Boolean theCopyGeom = Standard_False,
const Standard_Boolean theCopyMesh = Standard_False);
//! Returns the modified shape corresponding to <S>.
Standard_EXPORT virtual TopoDS_Shape ModifiedShape (const TopoDS_Shape& S) const Standard_OVERRIDE;

View File

@@ -26,6 +26,8 @@ BRepBuilderAPI_MakePolygon.cxx
BRepBuilderAPI_MakePolygon.hxx
BRepBuilderAPI_MakeShape.cxx
BRepBuilderAPI_MakeShape.hxx
BRepBuilderAPI_MakeShapeOnMesh.cxx
BRepBuilderAPI_MakeShapeOnMesh.hxx
BRepBuilderAPI_MakeShell.cxx
BRepBuilderAPI_MakeShell.hxx
BRepBuilderAPI_MakeSolid.cxx

View File

@@ -1585,7 +1585,7 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
NbSamples = 4;
gp_Pln FirstPlane;
PlaneOfWire(TopoDS::Wire(myWork(ideb)), FirstPlane);
gp_Pnt FirstBary = FirstPlane.Location();
gp_Pnt PrevBary = FirstPlane.Location();
gp_Vec NormalOfFirstPlane = FirstPlane.Axis().Direction();
for (i = ideb+1; i <= ifin; i++)
{
@@ -1596,10 +1596,10 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
gp_Pln CurPlane;
PlaneOfWire(aWire, CurPlane);
gp_Pnt CurBary = CurPlane.Location();
gp_Vec aVec(FirstBary, CurBary);
gp_Vec aVec(PrevBary, CurBary);
gp_Vec anOffsetProj = (aVec * NormalOfFirstPlane) * NormalOfFirstPlane;
CurBary.Translate(-anOffsetProj); //projected current bary center
gp_Vec Offset(CurBary, FirstBary);
gp_Vec Offset(CurBary, PrevBary);
TopoDS_Wire newwire;
BRep_Builder BB;
@@ -1804,6 +1804,8 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
newwire.Closed( Standard_True );
newwire.Orientation( TopAbs_FORWARD );
myWork(i) = newwire;
PrevBary = CurBary;
}
#ifdef OCCT_DEBUG_EFV

View File

@@ -124,10 +124,12 @@ void BRepMesh_DefaultRangeSplitter::computeTolerance(
const Standard_Real aDiffU = myRangeU.second - myRangeU.first;
const Standard_Real aDiffV = myRangeV.second - myRangeV.first;
// Slightly increase exact resolution so to cover links with approximate
// length equal to resolution itself on sub-resolution differences.
const Standard_Real aTolerance = BRep_Tool::Tolerance (myDFace->GetFace());
const Adaptor3d_Surface& aSurface = GetSurface()->Surface();
const Standard_Real aResU = aSurface.UResolution (aTolerance);
const Standard_Real aResV = aSurface.VResolution (aTolerance);
const Standard_Real aResU = aSurface.UResolution (aTolerance) * 1.1;
const Standard_Real aResV = aSurface.VResolution (aTolerance) * 1.1;
const Standard_Real aDeflectionUV = 1.e-05;
myTolerance.first = Max(Min(aDeflectionUV, aResU), 1e-7 * aDiffU);

View File

@@ -46,7 +46,8 @@ namespace
void operator()(const Standard_Integer theFaceIndex) const
{
const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex);
if (aDFace->IsSet(IMeshData_Outdated))
if (aDFace->IsSet(IMeshData_Outdated) ||
aDFace->GetFace().IsNull())
{
return;
}
@@ -119,7 +120,7 @@ namespace
void operator()(const Standard_Integer theFaceIndex) const
{
const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex);
if (aDFace->GetSurface()->GetType() != GeomAbs_Cone)
if (aDFace->GetSurface()->GetType() != GeomAbs_Cone || aDFace->IsSet(IMeshData_Failure))
{
return;
}
@@ -128,7 +129,7 @@ namespace
for (Standard_Integer aEdgeIdx = 0; aEdgeIdx < aDWire->EdgesNb() - 1; ++aEdgeIdx)
{
const IMeshData::IEdgePtr& aDEdge = aDWire->GetEdge (aEdgeIdx);
if (aDEdge->GetPCurve(aDFace.get(), TopAbs_FORWARD) != aDEdge->GetPCurve(aDFace.get(), TopAbs_REVERSED))
{
if (aDEdge->GetCurve()->ParametersNb() == 2)
@@ -146,7 +147,7 @@ namespace
}
}
return;
}
}
}
}

View File

@@ -124,7 +124,14 @@ static Standard_Integer transform(Draw_Interpretor&,Standard_Integer n,const cha
Standard_Boolean isBasic = Standard_False;
Standard_Boolean isForced = Standard_False;
Standard_Boolean isCopy = Standard_False;
Standard_Boolean isCopyMesh = Standard_False;
// Check "copymesh" flag.
if (!strcmp(a[n - 1], "-copymesh"))
{
isCopyMesh = Standard_True;
last = --n;
}
// Check "copy" flag.
if (!strcmp(a[n-1], "-copy")) {
isCopy = Standard_True;
@@ -218,7 +225,7 @@ static Standard_Integer transform(Draw_Interpretor&,Standard_Integer n,const cha
return 1;
}
else {
trf.Perform(S, isCopy);
trf.Perform(S, isCopy, isCopyMesh);
if (!trf.IsDone())
return 1;
DBRep::Set(a[i],trf.Shape());
@@ -1487,27 +1494,27 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
transform,g);
theCommands.Add("tmove",
"tmove name1 name2 ... name, set location from name [-copy]",
"tmove name1 name2 ... name, set location from name [-copy] [-copymesh]",
__FILE__,
transform,g);
theCommands.Add("ttranslate",
"ttranslate name1 name2 ... dx dy dz [-copy]",
"ttranslate name1 name2 ... dx dy dz [-copy [-copymesh]]",
__FILE__,
transform,g);
theCommands.Add("trotate",
"trotate name1 name2 ... x y z dx dy dz angle [-copy]",
"trotate name1 name2 ... x y z dx dy dz angle [-copy [-copymesh]]",
__FILE__,
transform,g);
theCommands.Add("tmirror",
"tmirror name x y z dx dy dz [-copy]",
"tmirror name x y z dx dy dz [-copy] [-copymesh]",
__FILE__,
transform,g);
theCommands.Add("tscale",
"tscale name x y z scale [-copy]",
"tscale name x y z scale [-copy] [-copymesh]",
__FILE__,
transform,g);

View File

@@ -893,6 +893,8 @@ void BRepTools::CleanGeometry(const TopoDS_Shape& theShape)
aBuilder.UpdateEdge(anEdge, Handle(Geom_Curve)(),
TopLoc_Location(), BRep_Tool::Tolerance(anEdge));
}
RemoveUnusedPCurves(theShape);
}

View File

@@ -0,0 +1,215 @@
// Copyright (c) 1999-2022 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 <BRepTools_CopyModification.hxx>
#include <BRep_Tool.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Vertex.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_CopyModification, BRepTools_Modification)
//=======================================================================
//function : BRepTools_CopyModification
//purpose :
//=======================================================================
BRepTools_CopyModification::BRepTools_CopyModification(const Standard_Boolean copyGeom,
const Standard_Boolean copyMesh)
: myCopyGeom(copyGeom),
myCopyMesh(copyMesh)
{
}
//=======================================================================
//function : NewSurface
//purpose :
//=======================================================================
Standard_Boolean BRepTools_CopyModification::NewSurface(const TopoDS_Face& theFace,
Handle(Geom_Surface)& theSurf,
TopLoc_Location& theLoc,
Standard_Real& theTol,
Standard_Boolean& theRevWires,
Standard_Boolean& theRevFace)
{
theSurf = BRep_Tool::Surface(theFace, theLoc);
theTol = BRep_Tool::Tolerance(theFace);
theRevWires = theRevFace = Standard_False;
if (!theSurf.IsNull() && myCopyGeom)
theSurf = Handle(Geom_Surface)::DownCast(theSurf->Copy());
return Standard_True;
}
//=======================================================================
//function : NewTriangulation
//purpose :
//=======================================================================
Standard_Boolean BRepTools_CopyModification::NewTriangulation(const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTri)
{
if (!myCopyMesh && BRep_Tool::IsGeometric(theFace))
{
return Standard_False;
}
TopLoc_Location aLoc;
theTri = BRep_Tool::Triangulation(theFace, aLoc);
if (theTri.IsNull())
return Standard_False;
// mesh is copied if and only if the geometry need to be copied too
if (myCopyGeom)
theTri = theTri->Copy();
return Standard_True;
}
//=======================================================================
//function : NewCurve
//purpose :
//=======================================================================
Standard_Boolean BRepTools_CopyModification::NewCurve(const TopoDS_Edge& theEdge,
Handle(Geom_Curve)& theCurve,
TopLoc_Location& theLoc,
Standard_Real& theTol)
{
Standard_Real aFirst, aLast;
theCurve = BRep_Tool::Curve(theEdge, theLoc, aFirst, aLast);
theTol = BRep_Tool::Tolerance(theEdge);
if (!theCurve.IsNull() && myCopyGeom)
theCurve = Handle(Geom_Curve)::DownCast(theCurve->Copy());
return Standard_True;
}
//=======================================================================
//function : NewPolygon
//purpose :
//=======================================================================
Standard_Boolean BRepTools_CopyModification::NewPolygon(const TopoDS_Edge& theEdge,
Handle(Poly_Polygon3D)& thePoly)
{
if (!myCopyMesh && BRep_Tool::IsGeometric(theEdge))
{
return Standard_False;
}
TopLoc_Location aLoc;
thePoly = BRep_Tool::Polygon3D(theEdge, aLoc);
if (thePoly.IsNull())
return Standard_False;
// polygon is copied if and only if the geometry need to be copied too
if (myCopyGeom)
thePoly = thePoly->Copy();
return Standard_True;
}
//=======================================================================
//function : NewPolygonOnTriangulation
//purpose :
//=======================================================================
Standard_Boolean BRepTools_CopyModification::NewPolygonOnTriangulation(
const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly)
{
if (!myCopyMesh && BRep_Tool::IsGeometric(theEdge))
{
return Standard_False;
}
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aTria = BRep_Tool::Triangulation(theFace, aLoc);
thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aTria, aLoc);
if (thePoly.IsNull())
return Standard_False;
// polygon is copied if and only if the geometry need to be copied too
if (myCopyGeom)
thePoly = thePoly->Copy();
return Standard_True;
}
//=======================================================================
//function : NewPoint
//purpose :
//=======================================================================
Standard_Boolean BRepTools_CopyModification::NewPoint(const TopoDS_Vertex& theVertex,
gp_Pnt& thePnt,
Standard_Real& theTol)
{
thePnt = BRep_Tool::Pnt(theVertex);
theTol = BRep_Tool::Tolerance(theVertex);
return Standard_True;
}
//=======================================================================
//function : NewCurve2d
//purpose :
//=======================================================================
Standard_Boolean BRepTools_CopyModification::NewCurve2d(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
const TopoDS_Edge&,
const TopoDS_Face&,
Handle(Geom2d_Curve)& theCurve,
Standard_Real& theTol)
{
theTol = BRep_Tool::Tolerance(theEdge);
Standard_Real aFirst, aLast;
theCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast);
if (!theCurve.IsNull() && myCopyGeom)
theCurve = Handle(Geom2d_Curve)::DownCast(theCurve->Copy());
return Standard_True;
}
//=======================================================================
//function : NewParameter
//purpose :
//=======================================================================
Standard_Boolean BRepTools_CopyModification::NewParameter(const TopoDS_Vertex& theVertex,
const TopoDS_Edge& theEdge,
Standard_Real& thePnt,
Standard_Real& theTol)
{
if (theVertex.IsNull())
return Standard_False; // infinite edge may have Null vertex
theTol = BRep_Tool::Tolerance(theVertex);
thePnt = BRep_Tool::Parameter(theVertex, theEdge);
return Standard_True;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape BRepTools_CopyModification::Continuity(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace1,
const TopoDS_Face& theFace2,
const TopoDS_Edge&,
const TopoDS_Face&,
const TopoDS_Face&)
{
return BRep_Tool::Continuity(theEdge, theFace1, theFace2);
}

View File

@@ -0,0 +1,124 @@
// Copyright (c) 1999-2022 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.
#ifndef _BRepTools_CopyModification_HeaderFile
#define _BRepTools_CopyModification_HeaderFile
#include <BRepTools_Modification.hxx>
class BRepTools_CopyModification;
DEFINE_STANDARD_HANDLE(BRepTools_CopyModification, BRepTools_Modification)
//! Tool class implementing necessary functionality for copying geometry and triangulation.
class BRepTools_CopyModification : public BRepTools_Modification
{
public:
//! Constructor.
//! \param[in] theCopyGeom indicates that the geomtery (surfaces and curves) should be copied
//! \param[in] theCopyMesh indicates that the triangulation should be copied
Standard_EXPORT explicit BRepTools_CopyModification(const Standard_Boolean theCopyGeom = Standard_True,
const Standard_Boolean theCopyMesh = Standard_True);
//! Returns true if theFace has been modified.
//! If the face has been modified:
//! - theSurf is the new geometry of the face,
//! - theLoc is its new location, and
//! - theTol is the new tolerance.
//! theRevWires, theRevFace are always set to false, because the orientaion is not changed.
Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& theFace,
Handle(Geom_Surface)& theSurf,
TopLoc_Location& theLoc,
Standard_Real& theTol,
Standard_Boolean& theRevWires,
Standard_Boolean& theRevFace) Standard_OVERRIDE;
//! Returns true if theEdge has been modified.
//! If the edge has been modified:
//! - theCurve is the new geometric support of the edge,
//! - theLoc is the new location, and
//! - theTol is the new tolerance.
//! If the edge has not been modified, this function
//! returns false, and the values of theCurve, theLoc and theTol are not significant.
Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& theEdge,
Handle(Geom_Curve)& theCurve,
TopLoc_Location& theLoc,
Standard_Real& theTol) Standard_OVERRIDE;
//! Returns true if theVertex has been modified.
//! If the vertex has been modified:
//! - thePnt is the new geometry of the vertex, and
//! - theTol is the new tolerance.
//! If the vertex has not been modified this function
//! returns false, and the values of thePnt and theTol are not significant.
Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& theVertex, gp_Pnt& thePnt, Standard_Real& theTol) Standard_OVERRIDE;
//! Returns true if theEdge has a new curve on surface on theFace.
//! If a new curve exists:
//! - theCurve is the new geometric support of the edge,
//! - theTol the new tolerance.
//! If no new curve exists, this function returns false, and
//! the values of theCurve and theTol are not significant.
Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
const TopoDS_Edge& theNewEdge,
const TopoDS_Face& theNewFace,
Handle(Geom2d_Curve)& theCurve,
Standard_Real& theTol) Standard_OVERRIDE;
//! Returns true if theVertex has a new parameter on theEdge.
//! If a new parameter exists:
//! - thePnt is the parameter, and
//! - theTol is the new tolerance.
//! If no new parameter exists, this function returns false,
//! and the values of thePnt and theTol are not significant.
Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& theVertex,
const TopoDS_Edge& theEdge,
Standard_Real& thePnt,
Standard_Real& theTol) Standard_OVERRIDE;
//! Returns the continuity of theNewEdge between theNewFace1 and theNewFace2.
//!
//! theNewEdge is the new edge created from theEdge. theNewFace1
//! (resp. theNewFace2) is the new face created from theFace1 (resp. theFace2).
Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace1,
const TopoDS_Face& theFace2,
const TopoDS_Edge& theNewEdge,
const TopoDS_Face& theNewFace1,
const TopoDS_Face& theNewFace2) Standard_OVERRIDE;
//! Returns true if the face has been modified according to changed triangulation.
//! If the face has been modified:
//! - theTri is a new triangulation on the face
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace, Handle(Poly_Triangulation)& theTri) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon.
//! If the edge has been modified:
//! - thePoly is a new polygon
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge, Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon on triangulation.
//! If the edge has been modified:
//! - thePoly is a new polygon on triangulation
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRepTools_CopyModification, BRepTools_Modification)
private:
Standard_Boolean myCopyGeom;
Standard_Boolean myCopyMesh;
};
#endif // _BRepTools_CopyModification_HeaderFile

View File

@@ -29,6 +29,7 @@
#include <GeomLib.hxx>
#include <gp_GTrsf.hxx>
#include <gp_Pnt.hxx>
#include <gp_Quaternion.hxx>
#include <gp_XYZ.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_Type.hxx>
@@ -88,7 +89,13 @@ Standard_Boolean BRepTools_GTrsfModification::NewSurface
gp_GTrsf gtrsf;
gtrsf.SetVectorialPart(myGTrsf.VectorialPart());
gtrsf.SetTranslationPart(myGTrsf.TranslationPart());
S = Handle(Geom_Surface)::DownCast(BRep_Tool::Surface(F,L)->Copy());
S = BRep_Tool::Surface(F, L);
if (S.IsNull())
{
//processing the case when there is no geometry
return Standard_False;
}
S = Handle(Geom_Surface)::DownCast(S->Copy());
Tol = BRep_Tool::Tolerance(F);
Tol *= myGScale;
@@ -173,7 +180,7 @@ Standard_Boolean BRepTools_GTrsfModification::NewCurve
C = new Geom_TrimmedCurve(C, f, l);
}
L.Identity() ;
return Standard_True;
return !C.IsNull();
}
//=======================================================================
@@ -214,6 +221,11 @@ Standard_Boolean BRepTools_GTrsfModification::NewCurve2d
Tol *= myGScale;
Standard_Real f,l;
C = BRep_Tool::CurveOnSurface(E,F,f,l);
if (C.IsNull())
{
//processing the case when there is no geometry
return Standard_False;
}
C = new Geom2d_TrimmedCurve(C, f, l);
return Standard_True;
}
@@ -251,4 +263,113 @@ GeomAbs_Shape BRepTools_GTrsfModification::Continuity
return BRep_Tool::Continuity(E,F1,F2);
}
//=======================================================================
//function : NewTriangulation
//purpose :
//=======================================================================
Standard_Boolean BRepTools_GTrsfModification::NewTriangulation(const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTriangulation)
{
TopLoc_Location aLoc;
theTriangulation = BRep_Tool::Triangulation(theFace, aLoc);
if (theTriangulation.IsNull())
{
return Standard_False;
}
gp_GTrsf aGTrsf;
aGTrsf.SetVectorialPart(myGTrsf.VectorialPart());
aGTrsf.SetTranslationPart(myGTrsf.TranslationPart());
aGTrsf.Multiply(aLoc.Transformation());
theTriangulation = theTriangulation->Copy();
theTriangulation->SetCachedMinMax(Bnd_Box()); // clear bounding box
theTriangulation->Deflection(theTriangulation->Deflection() * Abs(myGScale));
// apply transformation to 3D nodes
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
{
gp_Pnt aP = theTriangulation->Node(anInd);
aGTrsf.Transforms(aP.ChangeCoord());
theTriangulation->SetNode(anInd, aP);
}
// modify triangles orientation in case of mirror transformation
if (myGScale < 0.0)
{
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
{
Poly_Triangle aTria = theTriangulation->Triangle(anInd);
Standard_Integer aN1, aN2, aN3;
aTria.Get(aN1, aN2, aN3);
aTria.Set(aN1, aN3, aN2);
theTriangulation->SetTriangle(anInd, aTria);
}
}
// modify normals
if (theTriangulation->HasNormals())
{
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
{
gp_Dir aNormal = theTriangulation->Normal(anInd);
aNormal.Transform(aGTrsf.Trsf());
theTriangulation->SetNormal(anInd, aNormal);
}
}
return Standard_True;
}
//=======================================================================
//function : NewPolygon
//purpose :
//=======================================================================
Standard_Boolean BRepTools_GTrsfModification::NewPolygon(const TopoDS_Edge& theEdge,
Handle(Poly_Polygon3D)& thePoly)
{
TopLoc_Location aLoc;
thePoly = BRep_Tool::Polygon3D(theEdge, aLoc);
if (thePoly.IsNull())
{
return Standard_False;
}
gp_GTrsf aGTrsf;
aGTrsf.SetVectorialPart(myGTrsf.VectorialPart());
aGTrsf.SetTranslationPart(myGTrsf.TranslationPart());
aGTrsf.Multiply(aLoc.Transformation());
thePoly = thePoly->Copy();
thePoly->Deflection(thePoly->Deflection() * Abs(myGScale));
// transform nodes
TColgp_Array1OfPnt& aNodesArray = thePoly->ChangeNodes();
for (Standard_Integer anId = aNodesArray.Lower(); anId <= aNodesArray.Upper(); ++anId)
{
gp_Pnt& aP = aNodesArray.ChangeValue(anId);
aGTrsf.Transforms(aP.ChangeCoord());
}
return Standard_True;
}
//=======================================================================
//function : NewPolygonOnTriangulation
//purpose :
//=======================================================================
Standard_Boolean BRepTools_GTrsfModification::NewPolygonOnTriangulation
(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly)
{
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(theFace, aLoc);
if (aT.IsNull())
{
return Standard_False;
}
thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aT, aLoc);
if (!thePoly.IsNull())
thePoly = thePoly->Copy();
return Standard_True;
}

View File

@@ -101,6 +101,25 @@ public:
//! (resp. <F2>).
Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const TopoDS_Edge& NewE, const TopoDS_Face& NewF1, const TopoDS_Face& NewF2) Standard_OVERRIDE;
//! Returns true if the face has been modified according to changed triangulation.
//! If the face has been modified:
//! - theTri is a new triangulation on the face
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTri) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon.
//! If the edge has been modified:
//! - thePoly is a new polygon
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge,
Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon on triangulation.
//! If the edge has been modified:
//! - thePoly is a new polygon on triangulation
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;

View File

@@ -20,7 +20,10 @@
#include <BRep_TEdge.hxx>
#include <BRepTools.hxx>
#include <ElSLib.hxx>
#include <Extrema_ExtPC2d.hxx>
#include <Extrema_GenLocateExtPS.hxx>
#include <Extrema_LocateExtPC.hxx>
#include <Extrema_LocateExtPC2d.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
@@ -47,30 +50,163 @@
#include <TopLoc_Location.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Builder.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_Modification)
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_CopyModification)
//
static void GeomLib_ChangeUBounds(Handle(Geom_BSplineSurface)& aSurface,
const Standard_Real newU1,
const Standard_Real newU2)
namespace
{
TColStd_Array1OfReal knots(1,aSurface->NbUKnots()) ;
aSurface->UKnots(knots) ;
BSplCLib::Reparametrize(newU1,
newU2,
knots) ;
aSurface->SetUKnots(knots) ;
}
static void GeomLib_ChangeVBounds(Handle(Geom_BSplineSurface)& aSurface,
const Standard_Real newV1,
const Standard_Real newV2)
{
TColStd_Array1OfReal knots(1,aSurface->NbVKnots()) ;
aSurface->VKnots(knots) ;
BSplCLib::Reparametrize(newV1,
newV2,
knots) ;
aSurface->SetVKnots(knots) ;
static void GeomLib_ChangeUBounds(Handle(Geom_BSplineSurface)& aSurface,
const Standard_Real newU1,
const Standard_Real newU2)
{
TColStd_Array1OfReal knots(1, aSurface->NbUKnots());
aSurface->UKnots(knots);
BSplCLib::Reparametrize(newU1, newU2, knots);
aSurface->SetUKnots(knots);
}
static void GeomLib_ChangeVBounds(Handle(Geom_BSplineSurface)& aSurface,
const Standard_Real newV1,
const Standard_Real newV2)
{
TColStd_Array1OfReal knots(1, aSurface->NbVKnots());
aSurface->VKnots(knots);
BSplCLib::Reparametrize(newV1, newV2, knots);
aSurface->SetVKnots(knots);
}
// find 3D curve from theEdge in theMap, and return the transformed curve or NULL
static Handle(Geom_Curve) newCurve(const TColStd_IndexedDataMapOfTransientTransient& theMap,
const TopoDS_Edge& theEdge,
Standard_Real& theFirst,
Standard_Real& theLast)
{
Handle(Geom_Curve) aNewCurve;
TopLoc_Location aLoc;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aLoc, theFirst, theLast);
if (!aCurve.IsNull() && theMap.Contains(aCurve))
{
aNewCurve = Handle(Geom_Curve)::DownCast(theMap.FindFromKey(aCurve));
aNewCurve = Handle(Geom_Curve)::DownCast(aNewCurve->Transformed(aLoc.Transformation()));
}
return aNewCurve;
}
// find 2D curve from theEdge on theFace in theMap, and return the transformed curve or NULL
static Handle(Geom2d_Curve) newCurve(const TColStd_IndexedDataMapOfTransientTransient& theMap,
const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Standard_Real& theFirst,
Standard_Real& theLast)
{
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theEdge, theFace, theFirst, theLast);
return (!aC2d.IsNull() && theMap.Contains(aC2d)) ? Handle(Geom2d_Curve)::DownCast(theMap.FindFromKey(aC2d))
: Handle(Geom2d_Curve)();
}
// find surface from theFace in theMap, and return the transformed surface or NULL
static Handle(Geom_Surface) newSurface(const TColStd_IndexedDataMapOfTransientTransient& theMap,
const TopoDS_Face& theFace)
{
Handle(Geom_Surface) aNewSurf;
TopLoc_Location aLoc;
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
if (!aSurf.IsNull() && theMap.Contains(aSurf))
{
aNewSurf = Handle(Geom_Surface)::DownCast(theMap.FindFromKey(aSurf));
aNewSurf = Handle(Geom_Surface)::DownCast(aNewSurf->Transformed(aLoc.Transformation()));
}
return aNewSurf;
}
static Standard_Boolean newParameter(const gp_Pnt& thePoint,
const Handle(Geom_Curve)& theCurve,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTol,
Standard_Real& theParam)
{
GeomAdaptor_Curve anAdaptor(theCurve);
Extrema_LocateExtPC proj(thePoint, anAdaptor, theParam, theFirst, theLast, Precision::PConfusion());
if (proj.IsDone())
{
Standard_Real aDist2Min = proj.SquareDistance();
if (aDist2Min < theTol * theTol)
{
theParam = proj.Point().Parameter();
return Standard_True;
}
}
return Standard_False;
}
static Standard_Boolean newParameter(const gp_Pnt2d& theUV,
const Handle(Geom2d_Curve)& theCurve2d,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTol,
Standard_Real& theParam)
{
Geom2dAdaptor_Curve anAdaptor(theCurve2d);
Extrema_LocateExtPC2d aProj(theUV, anAdaptor, theParam, Precision::PConfusion());
if (aProj.IsDone())
{
Standard_Real aDist2Min = aProj.SquareDistance();
if (aDist2Min < theTol * theTol)
{
theParam = aProj.Point().Parameter();
return Standard_True;
}
}
else
{
// Try to use general extrema to find the parameter, because Extrema_LocateExtPC2d
// sometimes could not find a solution if the parameter's first approach is several
// spans away from the expected solution (test bugs/modalg_7/bug28722).
Extrema_ExtPC2d anExt(theUV, anAdaptor, theFirst, theLast);
if (anExt.IsDone())
{
Standard_Integer aMinInd = 0;
Standard_Real aMinSqDist = Precision::Infinite();
for (Standard_Integer anIndex = 1; anIndex <= anExt.NbExt(); ++anIndex)
if (anExt.SquareDistance(anIndex) < aMinSqDist)
{
aMinSqDist = anExt.SquareDistance(anIndex);
aMinInd = anIndex;
}
if (aMinSqDist < theTol * theTol)
{
theParam = anExt.Point(aMinInd).Parameter();
return Standard_True;
}
}
}
return Standard_False;
}
static Standard_Boolean newUV(const gp_Pnt& thePoint,
const Handle(Geom_Surface)& theSurf,
const Standard_Real theTol,
gp_Pnt2d& theUV)
{
GeomAdaptor_Surface anAdaptor(theSurf);
Extrema_GenLocateExtPS aProj(anAdaptor);
aProj.Perform(thePoint, theUV.X(), theUV.Y());
if (aProj.IsDone())
{
Standard_Real aDist2Min = aProj.SquareDistance();
if (aDist2Min < theTol * theTol)
{
gp_XY& aUV = theUV.ChangeCoord();
aProj.Point().Parameter(aUV.ChangeCoord(1), aUV.ChangeCoord(2));
return Standard_True;
}
}
return Standard_False;
}
}
//=======================================================================
@@ -102,6 +238,12 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
RevWires = Standard_False;
RevFace = Standard_False;
Handle(Geom_Surface) SS = BRep_Tool::Surface(F,L);
if (SS.IsNull())
{
//processing the case when there is no geometry
return Standard_False;
}
Handle(Standard_Type) TheTypeSS = SS->DynamicType();
if ((TheTypeSS == STANDARD_TYPE(Geom_BSplineSurface)) ||
(TheTypeSS == STANDARD_TYPE(Geom_BezierSurface))) {
@@ -115,7 +257,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
//OCC466(apo)->
U1 = curvU1; U2 = curvU2;
V1 = curvV1; V2 = curvV2;
SS->Bounds(surfU1,surfU2,surfV1,surfV2);
S->Bounds(surfU1,surfU2,surfV1,surfV2);
if (Abs(U1 - surfU1) <= TolPar)
U1 = surfU1;
@@ -192,10 +334,10 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
if (Abs(surfU1-U1) > Tol || Abs(surfU2-U2) > Tol ||
Abs(surfV1-V1) > Tol || Abs(surfV2-V2) > Tol)
SS = new Geom_RectangularTrimmedSurface(S, U1, U2, V1, V2);
SS->Bounds(surfU1,surfU2,surfV1,surfV2);
S = new Geom_RectangularTrimmedSurface(S, U1, U2, V1, V2);
S->Bounds(surfU1,surfU2,surfV1,surfV2);
S = GeomConvert::SurfaceToBSplineSurface(SS);
S = GeomConvert::SurfaceToBSplineSurface(S);
Handle(Geom_BSplineSurface) BS = Handle(Geom_BSplineSurface)::DownCast(S) ;
BS->Resolution(Tol, UTol, VTol) ;
@@ -210,6 +352,9 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
GeomLib_ChangeVBounds(BS, V1, V2) ;
}
if (!myMap.Contains(SS)) {
myMap.Add(SS, S);
}
return Standard_True;
}
@@ -234,6 +379,41 @@ static Standard_Boolean IsConvert(const TopoDS_Edge& E)
}
//=======================================================================
//function : NewTriangulation
//purpose :
//=======================================================================
Standard_Boolean BRepTools_NurbsConvertModification::NewTriangulation(const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTri)
{
if (!BRepTools_CopyModification::NewTriangulation(theFace, theTri))
{
return Standard_False;
}
// convert UV nodes of the mesh
if (theTri->HasUVNodes())
{
TopLoc_Location aLoc;
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
Handle(Geom_Surface) aNewSurf = newSurface(myMap, theFace);
if (!aSurf.IsNull() && !aNewSurf.IsNull())
{
Standard_Real aTol = BRep_Tool::Tolerance(theFace);
for (Standard_Integer anInd = 1; anInd <= theTri->NbNodes(); ++anInd)
{
gp_Pnt2d aUV = theTri->UVNode(anInd);
gp_Pnt aPoint = aSurf->Value(aUV.X(), aUV.Y());
if (newUV(aPoint, aNewSurf, aTol, aUV))
theTri->SetUVNode(anInd, aUV);
}
}
}
return Standard_True;
}
//=======================================================================
//function : NewCurve
//purpose :
@@ -312,6 +492,40 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve
return Standard_True ;
}
//=======================================================================
//function : NewPolygon
//purpose :
//=======================================================================
Standard_Boolean BRepTools_NurbsConvertModification::NewPolygon(const TopoDS_Edge& theEdge,
Handle(Poly_Polygon3D)& thePoly)
{
if (!BRepTools_CopyModification::NewPolygon(theEdge, thePoly))
{
return Standard_False;
}
// update parameters of polygon
if (thePoly->HasParameters())
{
Standard_Real aTol = BRep_Tool::Tolerance(theEdge);
Standard_Real aFirst, aLast;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aFirst, aLast);
Handle(Geom_Curve) aNewCurve = newCurve(myMap, theEdge, aFirst, aLast);
if (!aCurve.IsNull() && !aNewCurve.IsNull()) // skip processing degenerated edges
{
TColStd_Array1OfReal& aParams = thePoly->ChangeParameters();
for (Standard_Integer anInd = aParams.Lower(); anInd <= aParams.Upper(); ++anInd)
{
Standard_Real& aParam = aParams(anInd);
gp_Pnt aPoint = aCurve->Value(aParam);
newParameter(aPoint, aNewCurve, aFirst, aLast, aTol, aParam);
}
}
}
return Standard_True;
}
//=======================================================================
//function : NewPoint
//purpose :
@@ -340,7 +554,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
Tol = BRep_Tool::Tolerance(E);
Standard_Real f2d,l2d;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f2d,l2d);
Handle(Geom2d_Curve) aBaseC2d = BRep_Tool::CurveOnSurface(E,F,f2d,l2d);
Standard_Real f3d,l3d;
TopLoc_Location Loc;
Handle(Geom_Curve) C3d = BRep_Tool::Curve(E, Loc, f3d,l3d);
@@ -348,6 +562,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
!C3d->IsKind(STANDARD_TYPE(Geom_BezierCurve))) ||
IsConvert(E));
Handle(Geom2d_Curve) C2d = aBaseC2d;
if(BRep_Tool::Degenerated(E)) {
//Curve2d = C2d;
if(!C2d->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)))
@@ -356,6 +571,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
C2d = aTrimC;
}
Curve2d = Geom2dConvert::CurveToBSplineCurve(C2d);
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
if(!BRepTools::IsReallyClosed(E,F)) {
@@ -381,9 +597,11 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
if(!newE.IsNull()) {
C3d = BRep_Tool::Curve(newE, f3d, l3d);
}
else {
if (C3d.IsNull()) {
C3d = BRep_Tool::Curve(E,f3d,l3d);
}
if (C3d.IsNull())
return Standard_False;
GeomAdaptor_Curve G3dAC(C3d, f3d, l3d);
Handle(GeomAdaptor_Curve) G3dAHC = new GeomAdaptor_Curve(G3dAC);
@@ -403,13 +621,16 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
Tol = newTol;
myUpdatedEdges.Append(newE);
}
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
return Standard_False;
}
}
else {
S = BRep_Tool::Surface(newF);
Handle(Geom_Surface) aNewS = BRep_Tool::Surface(newF);
if (!aNewS.IsNull())
S = aNewS;
}
S->Bounds(Uinf, Usup, Vinf, Vsup);
//Uinf -= 1e-9; Usup += 1e-9; Vinf -= 1e-9; Vsup += 1e-9;
@@ -451,6 +672,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
Tol = newTol;
myUpdatedEdges.Append(newE);
}
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
Curve2d = ProjOnCurve.BSpline();
@@ -460,6 +682,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
Tol = newTol;
myUpdatedEdges.Append(newE);
}
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
@@ -502,6 +725,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
Tol = newTol;
myUpdatedEdges.Append(newE);
}
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
else {
@@ -512,6 +736,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
Tol = newTol;
myUpdatedEdges.Append(newE);
}
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
}
@@ -557,6 +782,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
Tol = newTol;
myUpdatedEdges.Append(newE);
}
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
return Standard_False;
@@ -582,6 +808,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
Tol = newTol;
myUpdatedEdges.Append(newE);
}
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
return Standard_False;
@@ -629,6 +856,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
Tol = newTol;
myUpdatedEdges.Append(newE);
}
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
else {
@@ -640,6 +868,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
myUpdatedEdges.Append(newE);
}
mylcu.Append(C2dBis);
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
}
@@ -651,11 +880,58 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
return Standard_False;
}
Curve2d = Geom2dConvert::CurveToBSplineCurve(C2d);
myMap.Add(aBaseC2d, Curve2d);
return Standard_True;
}
}
}
//=======================================================================
//function : NewPolygonOnTriangulation
//purpose :
//=======================================================================
Standard_Boolean BRepTools_NurbsConvertModification::NewPolygonOnTriangulation(
const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly)
{
if (!BRepTools_CopyModification::NewPolygonOnTriangulation(theEdge, theFace, thePoly))
{
return Standard_False;
}
// update parameters of 2D polygon
if (thePoly->HasParameters())
{
Standard_Real aTol = Max(BRep_Tool::Tolerance(theEdge), thePoly->Deflection());
TopLoc_Location aLoc;
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
Handle(Geom_Surface) aNewSurf = newSurface(myMap, theFace);
Standard_Real aFirst, aLast;
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast);
Handle(Geom2d_Curve) aNewC2d = newCurve(myMap, theEdge, theFace, aFirst, aLast);
if (!aSurf.IsNull() && !aC2d.IsNull() && !aNewSurf.IsNull() && !aNewC2d.IsNull())
{
// compute 2D tolerance
GeomAdaptor_Surface aSurfAdapt(aSurf);
Standard_Real aTol2D = Max(aSurfAdapt.UResolution(aTol), aSurfAdapt.VResolution(aTol));
for (Standard_Integer anInd = 1; anInd <= thePoly->NbNodes(); ++anInd)
{
Standard_Real aParam = thePoly->Parameter(anInd);
gp_Pnt2d aUV = aC2d->Value(aParam);
gp_Pnt aPoint = aSurf->Value(aUV.X(), aUV.Y());
if (newUV(aPoint, aNewSurf, aTol, aUV) &&
newParameter(aUV, aNewC2d, aFirst, aLast, aTol2D, aParam))
{
thePoly->SetParameter(anInd, aParam);
}
}
}
}
return Standard_True;
}
//=======================================================================
//function : NewParameter
//purpose :
@@ -670,30 +946,12 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewParameter
Tol = BRep_Tool::Tolerance(V);
if(BRep_Tool::Degenerated(E))
return Standard_False;
Standard_Real f, l, param = BRep_Tool::Parameter(V,E);
TopLoc_Location L;
Handle(Geom_Curve) gc = BRep_Tool::Curve(E, L, f, l);
if(!myMap.Contains(gc))
return Standard_False;
Handle(Geom_BSplineCurve) gcc =
Handle(Geom_BSplineCurve)::DownCast(myMap.FindFromKey(gc));
gcc = Handle(Geom_BSplineCurve)::DownCast(gcc->Transformed(L.Transformation()));
GeomAdaptor_Curve ac(gcc);
gp_Pnt pnt = BRep_Tool::Pnt(V);
Extrema_LocateExtPC proj(pnt, ac, param, f, l, Tol);
if(proj.IsDone()) {
Standard_Real Dist2Min = proj.SquareDistance();
if (Dist2Min < Tol*Tol) {
P = proj.Point().Parameter();
return Standard_True;
}
}
return Standard_False;
P = BRep_Tool::Parameter(V,E);
Standard_Real aFirst, aLast;
Handle(Geom_Curve) aNewCurve = newCurve(myMap, E, aFirst, aLast);
return !aNewCurve.IsNull() && newParameter(pnt, aNewCurve, aFirst, aLast, Tol, P);
}
//=======================================================================

View File

@@ -22,7 +22,7 @@
#include <TopTools_ListOfShape.hxx>
#include <TColStd_ListOfTransient.hxx>
#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
#include <BRepTools_Modification.hxx>
#include <BRepTools_CopyModification.hxx>
#include <Standard_Real.hxx>
#include <GeomAbs_Shape.hxx>
class TopoDS_Face;
@@ -36,12 +36,12 @@ class Geom2d_Curve;
class BRepTools_NurbsConvertModification;
DEFINE_STANDARD_HANDLE(BRepTools_NurbsConvertModification, BRepTools_Modification)
DEFINE_STANDARD_HANDLE(BRepTools_NurbsConvertModification, BRepTools_CopyModification)
//! Defines a modification of the geometry by a Trsf
//! from gp. All methods return True and transform the
//! geometry.
class BRepTools_NurbsConvertModification : public BRepTools_Modification
class BRepTools_NurbsConvertModification : public BRepTools_CopyModification
{
public:
@@ -100,11 +100,27 @@ public:
//! (resp. <F2>).
Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const TopoDS_Edge& NewE, const TopoDS_Face& NewF1, const TopoDS_Face& NewF2) Standard_OVERRIDE;
//! Returns true if the face has been modified according to changed triangulation.
//! If the face has been modified:
//! - theTri is a new triangulation on the face
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace, Handle(Poly_Triangulation)& theTri) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon.
//! If the edge has been modified:
//! - thePoly is a new polygon
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge, Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon on triangulation.
//! If the edge has been modified:
//! - thePoly is a new polygon on triangulation
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
Standard_EXPORT const TopTools_ListOfShape& GetUpdatedEdges() const;
DEFINE_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_Modification)
DEFINE_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_CopyModification)
protected:

View File

@@ -23,6 +23,7 @@
#include <Geom_Surface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomLib.hxx>
#include <GeomLib_Tool.hxx>
#include <gp_GTrsf2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
@@ -43,7 +44,8 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepTools_TrsfModification,BRepTools_Modification)
//purpose :
//=======================================================================
BRepTools_TrsfModification::BRepTools_TrsfModification(const gp_Trsf& T) :
myTrsf(T)
myTrsf(T),
myCopyMesh(Standard_False)
{
}
@@ -58,6 +60,16 @@ gp_Trsf& BRepTools_TrsfModification::Trsf ()
return myTrsf;
}
//=======================================================================
//function : IsCopyMesh
//purpose :
//=======================================================================
Standard_Boolean& BRepTools_TrsfModification::IsCopyMesh()
{
return myCopyMesh;
}
//=======================================================================
//function : NewSurface
//purpose :
@@ -72,6 +84,12 @@ Standard_Boolean BRepTools_TrsfModification::NewSurface
Standard_Boolean& RevFace)
{
S = BRep_Tool::Surface(F,L);
if (S.IsNull())
{
//processing cases when there is no geometry
return Standard_False;
}
Tol = BRep_Tool::Tolerance(F);
Tol *= Abs(myTrsf.ScaleFactor());
RevWires = Standard_False;
@@ -87,6 +105,194 @@ Standard_Boolean BRepTools_TrsfModification::NewSurface
return Standard_True;
}
//=======================================================================
//function : NewTriangulation
//purpose :
//=======================================================================
Standard_Boolean BRepTools_TrsfModification::NewTriangulation
(const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTriangulation)
{
if (!myCopyMesh)
{
return Standard_False;
}
TopLoc_Location aLoc;
theTriangulation = BRep_Tool::Triangulation(theFace, aLoc);
if (theTriangulation.IsNull())
{
return Standard_False;
}
gp_Trsf aTrsf = myTrsf;
if (!aLoc.IsIdentity())
{
aTrsf = aLoc.Transformation().Inverted() * aTrsf * aLoc.Transformation();
}
theTriangulation = theTriangulation->Copy();
theTriangulation->SetCachedMinMax(Bnd_Box()); // clear bounding box
theTriangulation->Deflection(theTriangulation->Deflection() * Abs(myTrsf.ScaleFactor()));
// apply transformation to 3D nodes
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
{
gp_Pnt aP = theTriangulation->Node(anInd);
aP.Transform(aTrsf);
theTriangulation->SetNode(anInd, aP);
}
// modify 2D nodes
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
if (theTriangulation->HasUVNodes() && !aSurf.IsNull())
{
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
{
gp_Pnt2d aP2d = theTriangulation->UVNode(anInd);
aSurf->TransformParameters(aP2d.ChangeCoord().ChangeCoord(1),
aP2d.ChangeCoord().ChangeCoord(2),
myTrsf);
theTriangulation->SetUVNode(anInd, aP2d);
}
}
// modify triangles orientation in case of mirror transformation
if (myTrsf.ScaleFactor() < 0.0)
{
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
{
Poly_Triangle aTria = theTriangulation->Triangle(anInd);
Standard_Integer aN1, aN2, aN3;
aTria.Get(aN1, aN2, aN3);
aTria.Set(aN1, aN3, aN2);
theTriangulation->SetTriangle(anInd, aTria);
}
}
// modify normals
if (theTriangulation->HasNormals())
{
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
{
gp_Dir aNormal = theTriangulation->Normal(anInd);
aNormal.Transform(aTrsf);
theTriangulation->SetNormal(anInd, aNormal);
}
}
return Standard_True;
}
//=======================================================================
//function : NewPolygon
//purpose :
//=======================================================================
Standard_Boolean BRepTools_TrsfModification::NewPolygon
(const TopoDS_Edge& theE,
Handle(Poly_Polygon3D)& theP)
{
if (!myCopyMesh)
{
return Standard_False;
}
TopLoc_Location aLoc;
theP = BRep_Tool::Polygon3D(theE, aLoc);
if (theP.IsNull())
{
return Standard_False;
}
gp_Trsf aTrsf = myTrsf;
if (!aLoc.IsIdentity())
{
aTrsf = aLoc.Transformation().Inverted() * aTrsf * aLoc.Transformation();
}
theP = theP->Copy();
theP->Deflection(theP->Deflection() * Abs(myTrsf.ScaleFactor()));
TColgp_Array1OfPnt& aNodesArray = theP->ChangeNodes();
for (Standard_Integer anId = aNodesArray.Lower(); anId <= aNodesArray.Upper(); ++anId)
{
//Applying the transformation to each node of polygon
aNodesArray.ChangeValue(anId).Transform(aTrsf);
}
// transform the parametrization
if (theP->HasParameters())
{
TopLoc_Location aCurveLoc;
Standard_Real aFirst, aLast;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theE, aCurveLoc, aFirst, aLast);
if (!aCurve.IsNull())
{
Standard_Real aReparametrization = aCurve->ParametricTransformation(aTrsf);
if (Abs(aReparametrization - 1.0) > Precision::PConfusion())
{
TColStd_Array1OfReal& aParams = theP->ChangeParameters();
for (Standard_Integer anInd = aParams.Lower(); anInd <= aParams.Upper(); ++anInd)
{
aParams(anInd) *= aReparametrization;
}
}
}
}
return Standard_True;
}
//=======================================================================
//function : NewPolygonOnTriangulation
//purpose :
//=======================================================================
Standard_Boolean BRepTools_TrsfModification::NewPolygonOnTriangulation
(const TopoDS_Edge& theE,
const TopoDS_Face& theF,
Handle(Poly_PolygonOnTriangulation)& theP)
{
if (!myCopyMesh)
{
return Standard_False;
}
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(theF, aLoc);
if (aT.IsNull())
{
theP = Handle(Poly_PolygonOnTriangulation) ();
return Standard_False;
}
theP = BRep_Tool::PolygonOnTriangulation(theE, aT, aLoc);
if (theP.IsNull())
{
return Standard_False;
}
theP = theP->Copy();
theP->Deflection(theP->Deflection() * Abs(myTrsf.ScaleFactor()));
// transform the parametrization
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theF, aLoc);
Standard_Real aFirst, aLast;
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theE, theF, aFirst, aLast);
if (!aSurf.IsNull() && !aC2d.IsNull() && Abs(Abs(myTrsf.ScaleFactor()) - 1.0) > TopLoc_Location::ScalePrec())
{
gp_GTrsf2d aGTrsf = aSurf->ParametricTransformation(myTrsf);
if (aGTrsf.Form() != gp_Identity)
{
Handle(Geom2d_Curve) aNewC2d = GeomLib::GTransform(aC2d, aGTrsf);
for (Standard_Integer anInd = 1; anInd <= theP->NbNodes(); ++anInd)
{
Standard_Real aParam = theP->Parameter(anInd);
gp_Pnt2d aP2d = aC2d->Value(aParam);
aGTrsf.Transforms(aP2d.ChangeCoord());
GeomLib_Tool::Parameter(aNewC2d, aP2d, theP->Deflection(), aParam);
theP->SetParameter(anInd, aParam);
}
}
}
return Standard_True;
}
//=======================================================================
//function : NewCurve
@@ -101,6 +307,10 @@ Standard_Boolean BRepTools_TrsfModification::NewCurve
{
Standard_Real f,l;
C = BRep_Tool::Curve(E,L,f,l);
if (C.IsNull())
{
return Standard_False;
}
Tol = BRep_Tool::Tolerance(E);
Tol *= Abs(myTrsf.ScaleFactor());
@@ -153,6 +363,12 @@ Standard_Boolean BRepTools_TrsfModification::NewCurve2d
Standard_Real scale = myTrsf.ScaleFactor();
Tol *= Abs(scale);
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,loc);
if (S.IsNull())
{
// processing the case when the surface (geometry) is deleted
return Standard_False;
}
GeomAdaptor_Surface GAsurf(S);
if (GAsurf.GetType() == GeomAbs_Plane)
return Standard_False;

View File

@@ -50,6 +50,9 @@ public:
//! Provides access to the gp_Trsf associated with this
//! modification. The transformation can be changed.
Standard_EXPORT gp_Trsf& Trsf();
//! Sets a flag to indicate the need to copy mesh.
Standard_EXPORT Standard_Boolean& IsCopyMesh();
//! Returns true if the face F has been modified.
//! If the face has been modified:
@@ -64,6 +67,21 @@ public:
//! associated with this modification is negative.
Standard_EXPORT Standard_Boolean NewSurface (const TopoDS_Face& F, Handle(Geom_Surface)& S, TopLoc_Location& L, Standard_Real& Tol, Standard_Boolean& RevWires, Standard_Boolean& RevFace) Standard_OVERRIDE;
//! Returns true if the face has been modified according to changed triangulation.
//! If the face has been modified:
//! - T is a new triangulation on the face
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& F, Handle(Poly_Triangulation)& T) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon.
//! If the edge has been modified:
//! - P is a new polygon
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& E, Handle(Poly_Polygon3D)& P) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon on triangulation.
//! If the edge has been modified:
//! - P is a new polygon on triangulation
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& E, const TopoDS_Face& F, Handle(Poly_PolygonOnTriangulation)& P) Standard_OVERRIDE;
//! Returns true if the edge E has been modified.
//! If the edge has been modified:
//! - C is the new geometric support of the edge,
@@ -120,6 +138,7 @@ private:
gp_Trsf myTrsf;
Standard_Boolean myCopyMesh;
};

View File

@@ -1,5 +1,7 @@
BRepTools.cxx
BRepTools.hxx
BRepTools_CopyModification.cxx
BRepTools_CopyModification.hxx
BRepTools_DataMapIteratorOfMapOfVertexPnt2d.hxx
BRepTools_Debug.cxx
BRepTools_GTrsfModification.cxx

View File

@@ -51,7 +51,7 @@ Standard_Boolean BinMDF_TagSourceDriver::Paste
BinObjMgt_RRelocationTable& ) const
{
Handle(TDF_TagSource) aTag = Handle(TDF_TagSource)::DownCast(theTarget);
const Standard_Integer aValue = -1;
Standard_Integer aValue;
Standard_Boolean ok = theSource >> aValue;
if (ok)
aTag->Set(aValue);

View File

@@ -73,7 +73,7 @@ Standard_Boolean BinMDataStd_IntPackedMapDriver::Paste
}
if(aSize) {
Handle(TColStd_HPackedMapOfInteger) aHMap = new TColStd_HPackedMapOfInteger ();
const Standard_Integer aKey = -1;
Standard_Integer aKey;
for(Standard_Integer i = 0; i< aSize; i++) {
Standard_Boolean ok = Source >> aKey;
if (!ok) {

View File

@@ -54,7 +54,7 @@ Standard_Boolean BinMDataStd_IntegerDriver::Paste
BinObjMgt_RRelocationTable& theRT) const
{
Handle(TDataStd_Integer) anAtt = Handle(TDataStd_Integer)::DownCast(theTarget);
const Standard_Integer aValue = -1;
Standard_Integer aValue;
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);

View File

@@ -54,7 +54,7 @@ Standard_Boolean BinMDataStd_RealDriver::Paste
BinObjMgt_RRelocationTable& theRelocTable) const
{
Handle(TDataStd_Real) anAtt= Handle(TDataStd_Real)::DownCast(theTarget);
Standard_Real aValue = -1.0;
Standard_Real aValue;
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);

View File

@@ -54,7 +54,7 @@ Standard_Boolean BinMDataXtd_GeometryDriver::Paste
Handle(TDataXtd_Geometry) aT =
Handle(TDataXtd_Geometry)::DownCast (theTarget);
const Standard_Integer aType = -1;
Standard_Integer aType;
Standard_Boolean ok = theSource >> aType;
if (ok)
aT->SetType ((TDataXtd_GeometryEnum) aType);

View File

@@ -55,7 +55,7 @@ Standard_Boolean BinMDataXtd_PositionDriver::Paste
BinObjMgt_RRelocationTable& ) const
{
Handle(TDataXtd_Position) anAtt = Handle(TDataXtd_Position)::DownCast(theTarget);
Standard_Real aValue = 0.0;
Standard_Real aValue;
Standard_Boolean ok = theSource >> aValue;
if (!ok) return ok;
gp_Pnt aPosition(0., 0., 0.);

View File

@@ -56,7 +56,7 @@ Standard_Boolean BinMDataXtd_PresentationDriver::Paste
Handle(TDataXtd_Presentation) anAttribute = Handle(TDataXtd_Presentation)::DownCast(theTarget);
// Display status
const Standard_Integer aValue = -1;
Standard_Integer aValue;
ok = theSource >> aValue;
if (!ok) return ok;
anAttribute->SetDisplayed (aValue != 0);
@@ -92,7 +92,7 @@ Standard_Boolean BinMDataXtd_PresentationDriver::Paste
anAttribute->UnsetMaterial();
// Transparency
Standard_Real aRValue = -1.0;
Standard_Real aRValue;
ok = theSource >> aRValue;
if ( !ok ) return ok;
if ( aRValue != -1. )

View File

@@ -62,7 +62,7 @@ Standard_Boolean BinMFunction_FunctionDriver::Paste
Standard_Boolean ok = theSource >> aGUID;
if (ok) {
anAtt->SetDriverGUID(aGUID);
const Standard_Integer aValue = -1;
Standard_Integer aValue;
ok = theSource >> aValue;
if(ok)
anAtt->SetFailure(aValue);

View File

@@ -117,9 +117,8 @@ static int TranslateFrom (const BinObjMgt_Persistent& theSource,
TopoDS_Shape& theResult,
BinTools_ShapeSet* theShapeSet)
{
const Standard_Integer aShapeID = -1;
const Standard_Integer aLocID = -1;
const Standard_Character aCharOrient = '0';
Standard_Integer aShapeID, aLocID;
Standard_Character aCharOrient;
Standard_Boolean Ok = theSource >> aShapeID; //TShapeID;
if(!Ok) return 1;
// Read TShape and Orientation
@@ -177,11 +176,11 @@ Standard_Boolean BinMNaming_NamedShapeDriver::Paste
theSource >> aNbShapes;
TDF_Label aLabel = theTarget->Label ();
TNaming_Builder aBuilder (aLabel);
const Standard_Integer aVer = -1;
Standard_Integer aVer;
Standard_Boolean ok = theSource >> aVer;
if(!ok) return Standard_False;
aTAtt->SetVersion(aVer); //Version
const Standard_Character aCharEvol = '0';
Standard_Character aCharEvol;
ok = theSource >> aCharEvol;
if(!ok) return Standard_False;
TNaming_Evolution anEvol = EvolutionToEnum (aCharEvol); //Evolution

View File

@@ -152,7 +152,7 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
TNaming_Name& aName = anAtt->ChangeName();
TCollection_ExtendedString aMsg;
//1. NameType
const Standard_Character aValue = '0';
Standard_Character aValue;
Standard_Boolean ok = theSource >> aValue;
Standard_Boolean aNewF = Standard_False;
if (ok) {
@@ -171,7 +171,7 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
//3. Args
Standard_Integer aNbArgs=0;
const Standard_Integer anIndx = -1;
Standard_Integer anIndx;
Handle(TNaming_NamedShape) aNS;
ok = theSource >> aNbArgs;
if (ok) {

View File

@@ -48,9 +48,7 @@ Standard_Boolean BinMXCAFDoc_CentroidDriver::Paste(const BinObjMgt_Persistent& t
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
{
Handle(XCAFDoc_Centroid) anAtt = Handle(XCAFDoc_Centroid)::DownCast(theTarget);
Standard_Real x = 0.0;
Standard_Real y = 0.0;
Standard_Real z = 0.0;
Standard_Real x, y, z;
Standard_Boolean isOk = theSource >> x >> y >> z;
if(isOk) {
gp_Pnt aPnt(x, y, z);

View File

@@ -48,10 +48,8 @@ Standard_Boolean BinMXCAFDoc_ColorDriver::Paste(const BinObjMgt_Persistent& theS
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
{
Handle(XCAFDoc_Color) anAtt = Handle(XCAFDoc_Color)::DownCast(theTarget);
Standard_Real R = 0.0;
Standard_Real G = 0.0;
Standard_Real B = 0.0;
Standard_ShortReal alpha = 1.0;
Standard_Real R, G, B;
Standard_ShortReal alpha;
Standard_Boolean isOk = theSource >> R >> G >> B;
if(isOk) {
Standard_Boolean isRGBA = theSource >> alpha;

View File

@@ -54,6 +54,7 @@ static Standard_Byte faceCullToChar (Graphic3d_TypeOfBackfacingModel theMode)
{
case Graphic3d_TypeOfBackfacingModel_Auto: return '0';
case Graphic3d_TypeOfBackfacingModel_BackCulled: return 'B';
case Graphic3d_TypeOfBackfacingModel_FrontCulled: return 'F';
case Graphic3d_TypeOfBackfacingModel_DoubleSided: return '1';
}
return '0';
@@ -66,6 +67,7 @@ static Graphic3d_TypeOfBackfacingModel faceCullFromChar (Standard_Byte theMode)
{
case '0': return Graphic3d_TypeOfBackfacingModel_Auto;
case 'B': return Graphic3d_TypeOfBackfacingModel_BackCulled;
case 'F': return Graphic3d_TypeOfBackfacingModel_FrontCulled;
case '1': return Graphic3d_TypeOfBackfacingModel_DoubleSided;
}
return Graphic3d_TypeOfBackfacingModel_Auto;

View File

@@ -198,7 +198,7 @@ public:
Standard_Real LowerValue()
{
Standard_Integer a, aResultIndex = 0;
Standard_Real aValue = 0.0;
Standard_Real aValue;
for(a = myV.Length(); a > 0; a--)
{
if (aResultIndex == 0 || Abs(aValue) > Abs(myV.Value(a)))

View File

@@ -3915,7 +3915,7 @@ void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index)
}
TopoDS_Face FFv;
Standard_Real tol;
Standard_Integer prol = 0;
Standard_Integer prol;
BRep_Builder BRE;
Handle(Geom_Surface ) Sface;
Sface=BRep_Tool::Surface(Fv);

View File

@@ -1780,7 +1780,7 @@ void ChFi3d_ChBuilder::ExtentTwoCorner(const TopoDS_Vertex& V,
Standard_Integer Sens = 0;
ChFiDS_ListIteratorOfListOfStripe itel(LS);
Standard_Boolean FF = Standard_True;
Standard_Boolean isfirst[2] = { Standard_True, Standard_True };
Standard_Boolean isfirst[2];
Standard_Integer Iedge[2];
Iedge[0] = 1;
Iedge[1] = 1;

View File

@@ -27,7 +27,14 @@
IMPLEMENT_STANDARD_RTTIEXT(DE_Wrapper, Standard_Transient)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "global";
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope ("global");
return aScope;
}
}
//=======================================================================
// function : DE_Wrapper
@@ -253,7 +260,7 @@ Standard_Boolean DE_Wrapper::Load(const TCollection_AsciiString& theResource,
Standard_Boolean DE_Wrapper::Load(const Handle(DE_ConfigurationContext)& theResource,
const Standard_Boolean theIsRecursive)
{
GlobalParameters.LengthUnit = theResource->RealVal("general.length.unit", GlobalParameters.LengthUnit, THE_CONFIGURATION_SCOPE);
GlobalParameters.LengthUnit = theResource->RealVal("general.length.unit", GlobalParameters.LengthUnit, THE_CONFIGURATION_SCOPE());
if (theIsRecursive)
{
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
@@ -326,7 +333,7 @@ TCollection_AsciiString DE_Wrapper::Save(const Standard_Boolean theIsRecursive,
aFormatIter.More(); aFormatIter.Next())
{
const TCollection_AsciiString& aFormat = aFormatIter.Key();
aResult += THE_CONFIGURATION_SCOPE + '.' + "priority" + '.' + aFormat + " :\t ";
aResult += THE_CONFIGURATION_SCOPE() + '.' + "priority" + '.' + aFormat + " :\t ";
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
{
@@ -337,7 +344,7 @@ TCollection_AsciiString DE_Wrapper::Save(const Standard_Boolean theIsRecursive,
}
aResult += "!Global parameters. Used for all providers\n";
aResult += "!Length scale unit value. Should be more the 0. Default value: 1.0(MM)\n";
aResult += THE_CONFIGURATION_SCOPE + ".general.length.unit :\t " + GlobalParameters.LengthUnit + "\n";
aResult += THE_CONFIGURATION_SCOPE() + ".general.length.unit :\t " + GlobalParameters.LengthUnit + "\n";
if (theIsRecursive)
{
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
@@ -525,7 +532,7 @@ Standard_Boolean DE_Wrapper::findProvider(const TCollection_AsciiString& thePath
//=======================================================================
void DE_Wrapper::sort(const Handle(DE_ConfigurationContext)& theResource)
{
const TCollection_AsciiString aScope(THE_CONFIGURATION_SCOPE + '.' + "priority");
const TCollection_AsciiString aScope(THE_CONFIGURATION_SCOPE() + '.' + "priority");
NCollection_List<Handle(DE_ConfigurationNode)> aVendors;
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())

View File

@@ -19,7 +19,14 @@
IMPLEMENT_STANDARD_RTTIEXT(DEBRepCascade_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
}
//=======================================================================
// function : DEBRepCascade_ConfigurationNode
@@ -48,7 +55,7 @@ DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode(const Handle(DE
//=======================================================================
bool DEBRepCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.WriteBinary =
theResource->BooleanVal("write.binary", InternalParameters.WriteBinary, aScope);
@@ -72,7 +79,7 @@ TCollection_AsciiString DEBRepCascade_ConfigurationNode::Save() const
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Write parameters:\n";

View File

@@ -19,7 +19,14 @@
IMPLEMENT_STANDARD_RTTIEXT(DEXCAFCascade_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
}
//=======================================================================
// function : DEXCAFCascade_ConfigurationNode
@@ -48,7 +55,7 @@ DEXCAFCascade_ConfigurationNode::DEXCAFCascade_ConfigurationNode(const Handle(DE
//=======================================================================
bool DEXCAFCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.ReadAppendMode = (PCDM_ReaderFilter::AppendMode)
theResource->IntegerVal("read.append.mode", InternalParameters.ReadAppendMode, aScope);
@@ -67,7 +74,7 @@ TCollection_AsciiString DEXCAFCascade_ConfigurationNode::Save() const
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Read parameters:\n";

View File

@@ -7,6 +7,10 @@ TKOpenGlesTest
TKViewerTest
TKDraw
TKMeshVS
TKXDECascade
TKTObj
TKBinTObj
TKXmlTObj
TKXDESTEP
TKSTEP
TKSTEPAttr
@@ -18,6 +22,7 @@ TKXSBase
TKVRML
TKSTL
TKRWMesh
TKXDE
TKBinXCAF
TKXmlXCAF
TKBin

View File

@@ -60,6 +60,7 @@ Font_TextFormatter::Font_TextFormatter()
myAlignY (Graphic3d_VTA_TOP),
myTabSize (8),
myWrappingWidth (0.0f),
myIsWordWrapping (true),
myLastSymbolWidth (0.0f),
myMaxSymbolWidth (0.0f),
//
@@ -249,6 +250,7 @@ void Font_TextFormatter::Format()
}
}
Standard_Utf32Char aCharPrev = 0;
for (Font_TextFormatter::Iterator aFormatterIt(*this);
aFormatterIt.More(); aFormatterIt.Next())
{
@@ -269,12 +271,30 @@ void Font_TextFormatter::Format()
Font_Rect aBndBox;
GlyphBoundingBox (aRectIter, aBndBox);
const Standard_ShortReal aNextXPos = aBndBox.Right - BottomLeft (aFirstCornerId).x();
if (aNextXPos > aMaxLineWidth) // wrap the line and do processing of the symbol
Standard_Boolean isCurWordFits = true;
if(myIsWordWrapping && IsSeparatorSymbol(aCharPrev))
{
for (Font_TextFormatter::Iterator aWordIt = aFormatterIt; aWordIt.More(); aWordIt.Next())
{
if (IsSeparatorSymbol(aWordIt.Symbol()))
{
break;
}
float aWordWidthPx = myCorners[aWordIt.SymbolPosition()].x() - myCorners[aRectIter].x();
if (aNextXPos + aWordWidthPx > aMaxLineWidth)
{
isCurWordFits = false;
break;
}
}
}
if (aNextXPos > aMaxLineWidth || !isCurWordFits) // wrap the line and do processing of the symbol
{
const Standard_Integer aLastRect = aRectIter - 1; // last rect on current line
newLine (aLastRect, aMaxLineWidth);
}
}
aCharPrev = aCharThis;
}
myBndWidth = aMaxLineWidth;

View File

@@ -220,6 +220,12 @@ public:
//! Returns text maximum width, zero means that the text is not bounded by width
Standard_ShortReal Wrapping() const { return myWrappingWidth; }
//! returns TRUE when trying not to break words when wrapping text
Standard_Boolean WordWrapping () const { return myIsWordWrapping; }
//! returns TRUE when trying not to break words when wrapping text
void SetWordWrapping (const Standard_Boolean theIsWordWrapping) { myIsWordWrapping = theIsWordWrapping; }
//! @return width of formatted text.
inline Standard_ShortReal ResultWidth() const
{
@@ -274,6 +280,14 @@ public:
return Standard_False;
}
//! Returns true if the symbol separates words when wrapping is enabled
static Standard_Boolean IsSeparatorSymbol (const Standard_Utf32Char& theSymbol)
{
return theSymbol == '\x0A' // new line
|| theSymbol == ' ' // space
|| theSymbol == '\x09'; // tab
}
DEFINE_STANDARD_RTTIEXT (Font_TextFormatter, Standard_Transient)
protected: //! @name class auxiliary methods
@@ -288,6 +302,7 @@ protected: //! @name configuration
Graphic3d_VerticalTextAlignment myAlignY; //!< vertical alignment style
Standard_Integer myTabSize; //!< horizontal tabulation width (number of space symbols)
Standard_ShortReal myWrappingWidth; //!< text is wrapped by the width if defined (more 0)
Standard_Boolean myIsWordWrapping; //!< if TRUE try not to break words when wrapping text (true by default)
Standard_ShortReal myLastSymbolWidth; //!< width of the last symbol
Standard_ShortReal myMaxSymbolWidth; //!< maximum symbol width of the formatter string

View File

@@ -20,3 +20,14 @@ GeomConvert_CompCurveToBSplineCurve.cxx
GeomConvert_CompCurveToBSplineCurve.hxx
GeomConvert_Units.cxx
GeomConvert_Units.hxx
GeomConvert_CurveToAnaCurve.cxx
GeomConvert_CurveToAnaCurve.hxx
GeomConvert_SurfToAnaSurf.cxx
GeomConvert_SurfToAnaSurf.hxx
GeomConvert_ConvType.hxx
GeomConvert_FuncSphereLSDist.cxx
GeomConvert_FuncSphereLSDist.hxx
GeomConvert_FuncCylinderLSDist.cxx
GeomConvert_FuncCylinderLSDist.hxx
GeomConvert_FuncConeLSDist.cxx
GeomConvert_FuncConeLSDist.hxx

View File

@@ -0,0 +1,23 @@
// Copyright (c) 2022 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.
#ifndef _GeomConvert_ConvType_HeaderFile
#define _GeomConvert_ConvType_HeaderFile
enum GeomConvert_ConvType
{
GeomConvert_Target,
GeomConvert_Simplest,
GeomConvert_MinGap
};
#endif // _GeomConvert_ConvType_HeaderFile

View File

@@ -0,0 +1,768 @@
// Created: 2001-05-21
//
// Copyright (c) 2001-2013 OPEN CASCADE SAS
//
// This file is part of commercial software by OPEN CASCADE SAS,
// furnished in accordance with the terms and conditions of the contract
// and with the inclusion of this copyright notice.
// This file or any part thereof may not be provided or otherwise
// made available to any third party.
//
// No ownership title to the software is transferred hereby.
//
// OPEN CASCADE SAS makes no representation or warranties with respect to the
// performance of this software, and specifically disclaims any responsibility
// for any damages, special or consequential, connected with its use.
#include <ElCLib.hxx>
#include <gce_MakeCirc.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Line.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <gp_Ax2.hxx>
#include <gp_Ax3.hxx>
#include <gp_Circ.hxx>
#include <gp_Lin.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <Precision.hxx>
#include <GeomConvert_CurveToAnaCurve.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <GeomAbs_CurveType.hxx>
#include <math_Vector.hxx>
#include <math_Matrix.hxx>
#include <math_Gauss.hxx>
GeomConvert_CurveToAnaCurve::GeomConvert_CurveToAnaCurve():
myGap(Precision::Infinite()),
myConvType(GeomConvert_MinGap),
myTarget(GeomAbs_Line)
{
}
GeomConvert_CurveToAnaCurve::GeomConvert_CurveToAnaCurve(const Handle(Geom_Curve)& C) :
myGap(Precision::Infinite()),
myConvType(GeomConvert_MinGap),
myTarget(GeomAbs_Line)
{
myCurve = C;
}
void GeomConvert_CurveToAnaCurve::Init(const Handle(Geom_Curve)& C)
{
myCurve = C;
myGap = Precision::Infinite();
}
//=======================================================================
//function : ConvertToAnalytical
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_CurveToAnaCurve::ConvertToAnalytical(const Standard_Real tol,
Handle(Geom_Curve)& theResultCurve,
const Standard_Real F, const Standard_Real L,
Standard_Real& NewF, Standard_Real& NewL)
{
if(myCurve.IsNull())
return Standard_False;
Handle(Geom_Curve) aCurve = myCurve;
while (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) aTrimmed = Handle(Geom_TrimmedCurve)::
DownCast(aCurve);
aCurve = aTrimmed->BasisCurve();
}
Handle(Geom_Curve) C = ComputeCurve(aCurve,tol,F, L, NewF, NewL, myGap, myConvType, myTarget);
if(C.IsNull()) return Standard_False;
theResultCurve = C;
return Standard_True;
}
//=======================================================================
//function : IsLinear
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_CurveToAnaCurve::IsLinear(const TColgp_Array1OfPnt& aPoles,
const Standard_Real tolerance,
Standard_Real& Deviation)
{
Standard_Integer nbPoles = aPoles.Length();
if(nbPoles < 2)
return Standard_False;
Standard_Real dMax = 0;
Standard_Integer iMax1=0,iMax2=0;
Standard_Integer i;
for(i = 1; i < nbPoles; i++)
for(Standard_Integer j = i+1; j <= nbPoles; j++) {
Standard_Real dist = aPoles(i).SquareDistance(aPoles(j));
if(dist > dMax) {
dMax = dist;
iMax1 = i;
iMax2 = j;
}
}
if (dMax < Precision::SquareConfusion())
return Standard_False;
Standard_Real tol2 = tolerance*tolerance;
gp_Vec avec (aPoles(iMax1),aPoles(iMax2)); gp_Dir adir (avec); gp_Lin alin (aPoles(iMax1),adir);
Standard_Real aMax = 0.;
for(i = 1; i <= nbPoles; i++) {
Standard_Real dist = alin.SquareDistance(aPoles(i));
if(dist > tol2)
return Standard_False;
if(dist > aMax)
aMax = dist;
}
Deviation = sqrt(aMax);
return Standard_True;
}
//=======================================================================
//function : GetLine
//purpose :
//=======================================================================
gp_Lin GeomConvert_CurveToAnaCurve::GetLine(const gp_Pnt& P1, const gp_Pnt& P2,
Standard_Real& cf, Standard_Real& cl)
{
gp_Vec avec(P1, P2); gp_Dir adir(avec); gp_Lin alin(P1, adir);
cf = ElCLib::Parameter(alin, P1);
cl = ElCLib::Parameter(alin, P2);
return alin;
}
//=======================================================================
//function : ComputeLine
//purpose :
//=======================================================================
Handle(Geom_Line) GeomConvert_CurveToAnaCurve::ComputeLine (const Handle(Geom_Curve)& curve,
const Standard_Real tolerance,
const Standard_Real c1, const Standard_Real c2,
Standard_Real& cf, Standard_Real& cl,
Standard_Real& Deviation)
{
Handle(Geom_Line) line;
if (curve.IsNull()) return line;
line = Handle(Geom_Line)::DownCast(curve); // qui sait
if (!line.IsNull()) {
cf = c1;
cl = c2;
Deviation = 0.;
return line;
}
gp_Pnt P1 = curve->Value (c1);
gp_Pnt P2 = curve->Value (c2);
if(P1.SquareDistance(P2) < Precision::SquareConfusion())
return line;
cf = c1; cl = c2;
Handle(TColgp_HArray1OfPnt) Poles;
Standard_Integer nbPoles;
Handle(Geom_BSplineCurve) bsc = Handle(Geom_BSplineCurve)::DownCast(curve);
if (!bsc.IsNull()) {
nbPoles = bsc->NbPoles();
Poles = new TColgp_HArray1OfPnt(1, nbPoles);
bsc->Poles(Poles->ChangeArray1());
}
else
{
Handle(Geom_BezierCurve) bzc = Handle(Geom_BezierCurve)::DownCast(curve);
if (!bzc.IsNull()) {
nbPoles = bzc->NbPoles();
Poles = new TColgp_HArray1OfPnt(1, nbPoles);
bzc->Poles(Poles->ChangeArray1());
}
else
{
nbPoles = 23;
Poles = new TColgp_HArray1OfPnt(1, nbPoles);
Standard_Real dt = (c2 - c1) / (nbPoles - 1);
Poles->SetValue(1, P1);
Poles->SetValue(nbPoles, P2);
Standard_Integer i;
for (i = 2; i < nbPoles; ++i)
{
Poles->SetValue(i, curve->Value(c1 + (i - 1) * dt));
}
}
}
if(!IsLinear(Poles->Array1(),tolerance,Deviation)) return line; // non
gp_Lin alin = GetLine (P1, P2, cf, cl);
line = new Geom_Line (alin);
return line;
}
//=======================================================================
//function : GetCircle
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_CurveToAnaCurve::GetCircle (gp_Circ& crc,
const gp_Pnt& P0,const gp_Pnt& P1, const gp_Pnt& P2)
{
// Control if points are not aligned (should be done by MakeCirc
Standard_Real aMaxCoord = Sqrt(Precision::Infinite());
if (Abs(P0.X()) > aMaxCoord || Abs(P0.Y()) > aMaxCoord || Abs(P0.Z()) > aMaxCoord)
return Standard_False;
if (Abs(P1.X()) > aMaxCoord || Abs(P1.Y()) > aMaxCoord || Abs(P1.Z()) > aMaxCoord)
return Standard_False;
if (Abs(P2.X()) > aMaxCoord || Abs(P2.Y()) > aMaxCoord || Abs(P2.Z()) > aMaxCoord)
return Standard_False;
// Building the circle
gce_MakeCirc mkc (P0,P1,P2);
if (!mkc.IsDone()) return Standard_False;
crc = mkc.Value();
if (crc.Radius() < gp::Resolution()) return Standard_False;
// Recalage sur P0
gp_Pnt PC = crc.Location();
gp_Ax2 axe = crc.Position();
gp_Vec VX (PC,P0);
axe.SetXDirection (VX);
crc.SetPosition (axe);
return Standard_True;
}
//=======================================================================
//function : ComputeCircle
//purpose :
//=======================================================================
Handle(Geom_Curve) GeomConvert_CurveToAnaCurve::ComputeCircle (const Handle(Geom_Curve)& c3d,
const Standard_Real tol,
const Standard_Real c1, const Standard_Real c2,
Standard_Real& cf, Standard_Real& cl,
Standard_Real& Deviation)
{
if (c3d->IsKind (STANDARD_TYPE(Geom_Circle))) {
cf = c1;
cl = c2;
Deviation = 0.;
Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast(c3d);
return aCirc;
}
Handle(Geom_Circle) circ;
gp_Pnt P0,P1,P2;
Standard_Real ca = (c1+c1+c2) / 3; Standard_Real cb = (c1+c2+c2) / 3;
P0 = c3d->Value(c1);
P1 = c3d->Value(ca);
P2 = c3d->Value(cb);
gp_Circ crc;
if (!GetCircle (crc,P0,P1,P2)) return circ;
// Reste a controler que c est bien un cercle : prendre 20 points
Standard_Real du = (c2-c1)/20;
Standard_Integer i;
Standard_Real aMax = 0.;
for (i = 0; i <= 20; i ++) {
Standard_Real u = c1+(du*i);
gp_Pnt PP = c3d->Value(u);
Standard_Real dist = crc.Distance(PP);
if (dist > tol) return circ; // not done
if (dist > aMax)
aMax = dist;
}
Deviation = aMax;
// defining the parameters
Standard_Real PI2 = 2 * M_PI;
cf = ElCLib::Parameter (crc,c3d->Value (c1));
cf = ElCLib::InPeriod(cf, 0., PI2);
//first parameter should be closed to zero
if(Abs(cf) < Precision::PConfusion() || Abs(PI2-cf) < Precision::PConfusion())
cf = 0.;
Standard_Real cm = ElCLib::Parameter (crc,c3d->Value ((c1+c2)/2.));
cm = ElCLib::InPeriod(cm, cf, cf + PI2);
cl = ElCLib::Parameter (crc,c3d->Value (c2));
cl = ElCLib::InPeriod(cl, cm, cm + PI2);
circ = new Geom_Circle (crc);
return circ;
}
//=======================================================================
// Compute Ellipse
//=======================================================================
//=======================================================================
//function : IsArrayPntPlanar
//purpose :
//=======================================================================
static Standard_Boolean IsArrayPntPlanar(const Handle(TColgp_HArray1OfPnt)& HAP,
gp_Dir& Norm, const Standard_Real prec)
{
Standard_Integer size = HAP->Length();
if(size<3)
return Standard_False;
gp_Pnt P1 = HAP->Value(1);
gp_Pnt P2 = HAP->Value(2);
gp_Pnt P3 = HAP->Value(3);
Standard_Real dist1 = P1.Distance(P2);
Standard_Real dist2 = P1.Distance(P3);
if( dist1<prec || dist2<prec )
return Standard_False;
gp_Vec V1(P1,P2);
gp_Vec V2(P1,P3);
if(V1.IsParallel(V2,prec))
return Standard_False;
gp_Vec NV = V1.Crossed(V2);
Standard_Integer i;
for (i = 1; i <= 3; ++i)
{
if (Precision::IsInfinite(NV.Coord(i)))
return Standard_False;
}
if(NV.Magnitude() < gp::Resolution())
return Standard_False;
if(size>3) {
for(i=4; i<=size; i++) {
gp_Pnt PN = HAP->Value(i);
dist1 = P1.Distance(PN);
if (dist1 < prec || Precision::IsInfinite(dist1))
{
return Standard_False;
}
gp_Vec VN(P1,PN);
if(!NV.IsNormal(VN,prec))
return Standard_False;
}
}
Norm = NV;
return Standard_True;
}
//=======================================================================
//function : ConicdDefinition
//purpose :
//=======================================================================
static Standard_Boolean ConicDefinition
( const Standard_Real a, const Standard_Real b1, const Standard_Real c,
const Standard_Real d1, const Standard_Real e1, const Standard_Real f,
const Standard_Boolean IsParab, const Standard_Boolean IsEllip,
gp_Pnt& Center, gp_Dir& MainAxis, Standard_Real& Rmin, Standard_Real& Rmax )
{
Standard_Real Xcen = 0.,Ycen = 0., Xax = 0.,Yax = 0.;
Standard_Real b,d,e;
// conic : a*x2 + 2*b*x*y + c*y2 + 2*d*x + 2*e*y + f = 0.
//Equation (a,b,c,d,e,f);
b = b1/2.; d = d1/2.; e = e1/2.; // chgt de variable
Standard_Real eps = 1.E-08; // ?? comme ComputedForm
if (IsParab) {
}
else {
// -> Conique a centre, cas general
// On utilise les Determinants des matrices :
// | a b d |
// gdet (3x3) = | b c e | et pdet (2X2) = | a b |
// | d e f | | b c |
Standard_Real gdet = a*c*f + 2*b*d*e - c*d*d - a*e*e - b*b*f;
Standard_Real pdet = a*c - b*b;
Xcen = (b*e - c*d) / pdet;
Ycen = (b*d - a*e) / pdet;
Standard_Real term1 = a-c;
Standard_Real term2 = 2*b;
Standard_Real cos2t;
Standard_Real auxil;
if (Abs(term2) <= eps && Abs(term1) <= eps) {
cos2t = 1.;
auxil = 0.;
}
else {
if (Abs(term1) < eps)
{
return Standard_False;
}
Standard_Real t2d = term2/term1; //skl 21.11.2001
cos2t = 1./sqrt(1+t2d*t2d);
auxil = sqrt (term1*term1 + term2*term2);
}
Standard_Real cost = sqrt ( (1+cos2t)/2. );
Standard_Real sint = sqrt ( (1-cos2t)/2. );
Standard_Real aprim = (a+c+auxil)/2.;
Standard_Real cprim = (a+c-auxil)/2.;
if (Abs(aprim) < gp::Resolution() || Abs(cprim) < gp::Resolution())
return Standard_False;
term1 = -gdet/(aprim*pdet);
term2 = -gdet/(cprim*pdet);
if (IsEllip) {
Xax = cost;
Yax = sint;
Rmin = sqrt ( term1);
Rmax = sqrt ( term2);
if(Rmax<Rmin){
Rmax = sqrt ( term1);
Rmin = sqrt ( term2);
}
}
else if (term1 <= eps){
Xax = -sint;
Yax = cost;
Rmin = sqrt (-term1);
Rmax = sqrt (term2);
}
else {
Xax = cost;
Yax = sint;
Rmin = sqrt (-term2);
Rmax = sqrt (term1);
}
}
Center.SetCoord (Xcen,Ycen,0.);
MainAxis.SetCoord (Xax,Yax,0.);
return Standard_True;
}
//=======================================================================
//function : ComputeEllipse
//purpose :
//=======================================================================
Handle(Geom_Curve) GeomConvert_CurveToAnaCurve::ComputeEllipse(const Handle(Geom_Curve)& c3d,
const Standard_Real tol,
const Standard_Real c1, const Standard_Real c2,
Standard_Real& cf, Standard_Real& cl,
Standard_Real& Deviation)
{
if (c3d->IsKind (STANDARD_TYPE(Geom_Ellipse))) {
cf = c1;
cl = c2;
Deviation = 0.;
Handle(Geom_Ellipse) anElips = Handle(Geom_Ellipse)::DownCast(c3d);
return anElips;
}
Handle(Geom_Curve) res;
Standard_Real prec = Precision::PConfusion();
Standard_Real AF,BF,CF,DF,EF,Q1,Q2,Q3,c2n;
Standard_Integer i;
gp_Pnt PStart = c3d->Value(c1);
gp_Pnt PEnd = c3d->Value(c2);
const Standard_Boolean IsClos = PStart.Distance(PEnd) < prec;
if (IsClos)
{
c2n=c2-(c2-c1)/5;
}
else
c2n=c2;
//
gp_XYZ aBC;
Handle(TColgp_HArray1OfPnt) AP = new TColgp_HArray1OfPnt(1,5);
AP->SetValue(1,PStart);
aBC += PStart.XYZ();
Standard_Real dc=(c2n-c1)/4;
for (i = 1; i < 5; i++)
{
gp_Pnt aP = c3d->Value(c1 + dc*i);
AP->SetValue(i + 1, aP);
aBC += aP.XYZ();
}
aBC /= 5;
aBC *= -1;
gp_Vec aTrans(aBC);
for (i = 1; i <= 5; ++i)
{
AP->ChangeValue(i).Translate(aTrans);
}
gp_Dir ndir;
if(!IsArrayPntPlanar(AP,ndir,prec))
return res;
if (Abs(ndir.X()) < gp::Resolution() && Abs(ndir.Y()) < gp::Resolution()
&& Abs(ndir.Z()) < gp::Resolution())
return res;
gp_Ax3 AX(gp_Pnt(0,0,0),ndir);
gp_Trsf Tr;
Tr.SetTransformation(AX);
gp_Trsf Tr2 = Tr.Inverted();
math_Matrix Dt(1, 5, 1, 5);
math_Vector F(1, 5), Sl(1, 5);
Standard_Real XN,YN,ZN = 0.;
gp_Pnt PT,PP;
for(i=1; i<=5; i++) {
PT = AP->Value(i).Transformed(Tr);
PT.Coord(XN,YN,ZN);
Dt(i, 1) = XN*XN;
Dt(i, 2) = XN*YN;
Dt(i, 3) = YN*YN;
Dt(i, 4) = XN;
Dt(i, 5) = YN;
F(i) = -1.;
}
math_Gauss aSolver(Dt);
if (!aSolver.IsDone())
return res;
aSolver.Solve(F, Sl);
AF=Sl(1);
BF=Sl(2);
CF=Sl(3);
DF=Sl(4);
EF=Sl(5);
Q1=AF*CF+BF*EF*DF/4-CF*DF*DF/4-BF*BF/4-AF*EF*EF/4;
Q2=AF*CF-BF*BF/4;
Q3=AF+CF;
Standard_Real Rmax, Rmin;
gp_Pnt Center;
gp_Dir MainAxis;
Standard_Boolean IsParab = Standard_False, IsEllip = Standard_False;
if (Q2 > 0 && Q1*Q3 < 0) {
// ellipse
IsEllip = Standard_True;
if (ConicDefinition(AF, BF, CF, DF, EF, 1., IsParab, IsEllip,
Center, MainAxis, Rmin, Rmax)) {
// create ellipse
if (Rmax - Rmin < Precision::Confusion())
{
return res; //really it is circle, which must be recognized in other method
}
aTrans *= -1;
Center.SetZ(ZN);
gp_Pnt NewCenter = Center.Transformed(Tr2);
gp_Pnt Ptmp(Center.X() + MainAxis.X() * 10,
Center.Y() + MainAxis.Y() * 10,
Center.Z() + MainAxis.Z() * 10);
gp_Pnt NewPtmp = Ptmp.Transformed(Tr2);
gp_Dir NewMainAxis(NewPtmp.X() - NewCenter.X(),
NewPtmp.Y() - NewCenter.Y(),
NewPtmp.Z() - NewCenter.Z());
gp_Ax2 ax2(NewCenter, ndir, NewMainAxis);
gp_Elips anEllipse(ax2, Rmax, Rmin);
anEllipse.Translate(aTrans);
Handle(Geom_Ellipse) gell = new Geom_Ellipse(anEllipse);
// test for 20 points
Standard_Real param2 = 0;
dc = (c2 - c1) / 20;
for (i = 1; i <= 20; i++) {
PP = c3d->Value(c1 + i*dc);
Standard_Real aPar = ElCLib::Parameter(anEllipse, PP);
Standard_Real dist = gell->Value(aPar).Distance(PP);
if (dist > tol) return res; // not done
if (dist > param2)
param2 = dist;
}
Deviation = param2;
Standard_Real PI2 = 2 * M_PI;
cf = ElCLib::Parameter(anEllipse, c3d->Value(c1));
cf = ElCLib::InPeriod(cf, 0., PI2);
//first parameter should be closed to zero
if (Abs(cf) < Precision::PConfusion() || Abs(PI2 - cf) < Precision::PConfusion())
cf = 0.;
Standard_Real cm = ElCLib::Parameter(anEllipse, c3d->Value((c1 + c2) / 2.));
cm = ElCLib::InPeriod(cm, cf, cf + PI2);
cl = ElCLib::Parameter(anEllipse, c3d->Value(c2));
cl = ElCLib::InPeriod(cl, cm, cm + PI2);
res = gell;
}
}
/*
if (Q2 < 0 && Q1 != 0) {
// hyberbola
}
if (Q2 == 0 && Q1 != 0) {
// parabola
}
*/
return res;
}
//=======================================================================
//function : ComputeCurve
//purpose :
//=======================================================================
Handle(Geom_Curve) GeomConvert_CurveToAnaCurve::ComputeCurve(const Handle(Geom_Curve)& theC3d,
const Standard_Real tolerance,
const Standard_Real c1, const Standard_Real c2,
Standard_Real& cf, Standard_Real& cl,
Standard_Real& theGap,
const GeomConvert_ConvType theConvType, const GeomAbs_CurveType theTarget)
{
cf = c1; cl = c2;
Handle(Geom_Curve) c3d, newc3d[3];
Standard_Integer i, imin = -1;
c3d = theC3d;
if (c3d.IsNull()) return newc3d[imin];
gp_Pnt P1 = c3d->Value(c1);
gp_Pnt P2 = c3d->Value(c2);
gp_Pnt P3 = c3d->Value(c1 + (c2 - c1) / 2);
Standard_Real d[3] = { RealLast(), RealLast(), RealLast() };
Standard_Real fp[3], lp[3];
if (c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) aTc = Handle(Geom_TrimmedCurve)::DownCast(c3d);
c3d = aTc->BasisCurve();
}
if (theConvType == GeomConvert_Target)
{
theGap = RealLast();
if (theTarget == GeomAbs_Line)
{
newc3d[0] = ComputeLine(c3d, tolerance, c1, c2, fp[0], lp[0], theGap);
cf = fp[0];
cl = lp[0];
return newc3d[0];
}
if (theTarget == GeomAbs_Circle)
{
newc3d[1] = ComputeCircle(c3d, tolerance, c1, c2, fp[1], lp[1], theGap);
cf = fp[1];
cl = lp[1];
return newc3d[1];
}
if (theTarget == GeomAbs_Ellipse)
{
newc3d[2] = ComputeEllipse(c3d, tolerance, c1, c2, fp[2], lp[2], theGap);
cf = fp[2];
cl = lp[2];
return newc3d[2];
}
}
//
if (theConvType == GeomConvert_Simplest)
{
theGap = RealLast();
newc3d[0] = ComputeLine(c3d, tolerance, c1, c2, fp[0], lp[0], theGap);
if (!newc3d[0].IsNull())
{
cf = fp[0];
cl = lp[0];
return newc3d[0];
}
theGap = RealLast();
newc3d[1] = ComputeCircle(c3d, tolerance, c1, c2, fp[1], lp[1], theGap);
if (!newc3d[1].IsNull())
{
cf = fp[1];
cl = lp[1];
return newc3d[1];
}
theGap = RealLast();
newc3d[2] = ComputeEllipse(c3d, tolerance, c1, c2, fp[2], lp[2], theGap);
if (!newc3d[2].IsNull())
{
cf = fp[2];
cl = lp[2];
return newc3d[2];
}
// Conversion failed, returns null curve
return newc3d[0];
}
// theConvType == GeomConvert_MinGap
// recognition in case of small curve
imin = -1;
if((P1.Distance(P2) < 2*tolerance) && (P1.Distance(P3) < 2*tolerance)) {
newc3d[1] = ComputeCircle(c3d, tolerance, c1, c2, fp[1], lp[1], d[1]);
newc3d[0] = ComputeLine(c3d, tolerance, c1, c2, fp[0], lp[0], d[0]);
imin = 1;
if (newc3d[1].IsNull() || d[0] < d[1])
{
imin = 0;
}
}
else {
d[0] = RealLast();
newc3d[0] = ComputeLine (c3d,tolerance,c1,c2,fp[0],lp[0],d[0]);
Standard_Real tol = Min(tolerance, d[0]);
if (!Precision::IsInfinite(c1) && !Precision::IsInfinite(c2))
{
d[1] = RealLast();
newc3d[1] = ComputeCircle(c3d, tol, c1, c2, fp[1], lp[1], d[1]);
tol = Min(tol, d[1]);
d[2] = RealLast();
newc3d[2] = ComputeEllipse(c3d, tol, c1, c2, fp[2], lp[2], d[2]);
}
Standard_Real dd = RealLast();
for (i = 0; i < 3; ++i)
{
if (newc3d[i].IsNull()) continue;
if (d[i] < dd)
{
dd = d[i];
imin = i;
}
}
}
if (imin >= 0)
{
cf = fp[imin];
cl = lp[imin];
theGap = d[imin];
return newc3d[imin];
}
else
{
cf = c1;
cl = c2;
theGap = -1.;
return newc3d[0]; // must be null curve;
}
}

View File

@@ -0,0 +1,133 @@
// Created: 2001-05-21
//
// Copyright (c) 2001-2013 OPEN CASCADE SAS
//
// This file is part of commercial software by OPEN CASCADE SAS,
// furnished in accordance with the terms and conditions of the contract
// and with the inclusion of this copyright notice.
// This file or any part thereof may not be provided or otherwise
// made available to any third party.
//
// No ownership title to the software is transferred hereby.
//
// OPEN CASCADE SAS makes no representation or warranties with respect to the
// performance of this software, and specifically disclaims any responsibility
// for any damages, special or consequential, connected with its use.
#ifndef _GeomConvert_CurveToAnaCurve_HeaderFile
#define _GeomConvert_CurveToAnaCurve_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <GeomConvert_ConvType.hxx>
#include <GeomAbs_CurveType.hxx>
class Geom_Curve;
class Geom_Line;
class gp_Lin;
class gp_Pnt;
class gp_Circ;
class GeomConvert_CurveToAnaCurve
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT GeomConvert_CurveToAnaCurve();
Standard_EXPORT GeomConvert_CurveToAnaCurve(const Handle(Geom_Curve)& C);
Standard_EXPORT void Init (const Handle(Geom_Curve)& C);
//! Converts me to analytical if possible with given
//! tolerance. The new first and last parameters are
//! returned to newF, newL
Standard_EXPORT Standard_Boolean ConvertToAnalytical (const Standard_Real theTol, Handle(Geom_Curve)& theResultCurve, const Standard_Real F, const Standard_Real L, Standard_Real& newF, Standard_Real& newL);
Standard_EXPORT static Handle(Geom_Curve) ComputeCurve (const Handle(Geom_Curve)& curve, const Standard_Real tolerance,
const Standard_Real c1, const Standard_Real c2, Standard_Real& cf, Standard_Real& cl,
Standard_Real& theGap, const GeomConvert_ConvType theCurvType = GeomConvert_MinGap, const GeomAbs_CurveType theTarget = GeomAbs_Line);
//! Tries to convert the given curve to circle with given
//! tolerance. Returns NULL curve if conversion is
//! not possible.
Standard_EXPORT static Handle(Geom_Curve) ComputeCircle (const Handle(Geom_Curve)& curve, const Standard_Real tolerance, const Standard_Real c1, const Standard_Real c2, Standard_Real& cf, Standard_Real& cl, Standard_Real& Deviation);
//! Tries to convert the given curve to ellipse with given
//! tolerance. Returns NULL curve if conversion is
//! not possible.
Standard_EXPORT static Handle(Geom_Curve) ComputeEllipse (const Handle(Geom_Curve)& curve, const Standard_Real tolerance, const Standard_Real c1, const Standard_Real c2, Standard_Real& cf, Standard_Real& cl, Standard_Real& Deviation);
//! Tries to convert the given curve to line with given
//! tolerance. Returns NULL curve if conversion is
//! not possible.
Standard_EXPORT static Handle(Geom_Line) ComputeLine (const Handle(Geom_Curve)& curve, const Standard_Real tolerance, const Standard_Real c1, const Standard_Real c2, Standard_Real& cf, Standard_Real& cl, Standard_Real& Deviation);
//! Returns true if the set of points is linear with given
//! tolerance
Standard_EXPORT static Standard_Boolean IsLinear (const TColgp_Array1OfPnt& aPoints, const Standard_Real tolerance, Standard_Real& Deviation);
//! Creates line on two points.
//! Resulting parameters returned
Standard_EXPORT static gp_Lin GetLine(const gp_Pnt& P1, const gp_Pnt& P2, Standard_Real& cf, Standard_Real& cl);
//! Creates circle on points. Returns true if OK.
Standard_EXPORT static Standard_Boolean GetCircle(gp_Circ& Circ, const gp_Pnt& P0, const gp_Pnt& P1, const gp_Pnt& P2);
//! Returns maximal deviation of converted surface from the original
//! one computed by last call to ConvertToAnalytical
Standard_Real Gap() const
{
return myGap;
}
//! Returns conversion type
GeomConvert_ConvType GetConvType() const
{
return myConvType;
}
//! Sets type of convertion
void SetConvType(const GeomConvert_ConvType theConvType)
{
myConvType = theConvType;
}
//! Returns target curve type
GeomAbs_CurveType GetTarget() const
{
return myTarget;
}
//! Sets target curve type
void SetTarget(const GeomAbs_CurveType theTarget)
{
myTarget = theTarget;
}
protected:
private:
Handle(Geom_Curve) myCurve;
Standard_Real myGap;
GeomConvert_ConvType myConvType;
GeomAbs_CurveType myTarget;
};
#endif // _GeomConvert_CurveToAnaCurve_HeaderFile

View File

@@ -0,0 +1,68 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2022 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 <GeomConvert_FuncConeLSDist.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Ax3.hxx>
#include <math_Vector.hxx>
#include <ElSLib.hxx>
//=======================================================================
//function : GeomConvert_FuncConeLSDist
//purpose :
//=======================================================================
GeomConvert_FuncConeLSDist::GeomConvert_FuncConeLSDist(
const Handle(TColgp_HArray1OfXYZ)& thePoints,
const gp_Dir& theDir):
myPoints(thePoints), myDir(theDir)
{
}
//=======================================================================
//function : NbVariables
//purpose :
//=======================================================================
Standard_Integer GeomConvert_FuncConeLSDist::NbVariables () const
{
return 5;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_FuncConeLSDist::Value(const math_Vector& X, Standard_Real& F)
{
gp_Pnt aLoc(X(1), X(2), X(3));
Standard_Real aSemiAngle = X(4), anR = X(5);
gp_Ax3 aPos(aLoc, myDir);
F = 0.;
Standard_Integer i;
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
{
Standard_Real u, v;
gp_Pnt aPi(myPoints->Value(i));
ElSLib::ConeParameters(aPos, anR, aSemiAngle, aPi, u, v);
gp_Pnt aPp;
ElSLib::ConeD0(u, v, aPos, anR, aSemiAngle, aPp);
F += aPi.SquareDistance(aPp);
}
return Standard_True;
}

View File

@@ -0,0 +1,66 @@
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2022 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.
#ifndef _GeomConvert_FuncConeLSDist_HeaderFile
#define _GeomConvert_FuncConeLSDist_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <math_MultipleVarFunction.hxx>
#include <TColgp_HArray1OfXYZ.hxx>
#include <math_Vector.hxx>
#include <gp_Dir.hxx>
//! Function for search of Cone canonic parameters: coordinates of center local coordinate system,
//! direction of axis, radius and semi-angle from set of points
//! by least square method.
//!
//!
class GeomConvert_FuncConeLSDist : public math_MultipleVarFunction
{
public:
DEFINE_STANDARD_ALLOC
//! Constructor.
Standard_EXPORT GeomConvert_FuncConeLSDist() {};
Standard_EXPORT GeomConvert_FuncConeLSDist(const Handle(TColgp_HArray1OfXYZ)& thePoints,
const gp_Dir& theDir);
void SetPoints(const Handle(TColgp_HArray1OfXYZ)& thePoints)
{
myPoints = thePoints;
}
void SetDir(const gp_Dir& theDir)
{
myDir = theDir;
}
//! Number of variables.
Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
//! Value.
Standard_EXPORT Standard_Boolean Value(const math_Vector& X,Standard_Real& F) Standard_OVERRIDE;
private:
Handle(TColgp_HArray1OfXYZ) myPoints;
gp_Dir myDir;
};
#endif // _GeomConvert_FuncConeLSDist_HeaderFile

View File

@@ -0,0 +1,140 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2022 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 <GeomConvert_FuncCylinderLSDist.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <math_Vector.hxx>
//=======================================================================
//function : GeomConvert_FuncCylinderLSDist
//purpose :
//=======================================================================
GeomConvert_FuncCylinderLSDist::GeomConvert_FuncCylinderLSDist(
const Handle(TColgp_HArray1OfXYZ)& thePoints,
const gp_Dir& theDir):
myPoints(thePoints), myDir(theDir)
{
}
//=======================================================================
//function : NbVariables
//purpose :
//=======================================================================
Standard_Integer GeomConvert_FuncCylinderLSDist::NbVariables () const
{
return 4;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_FuncCylinderLSDist::Value(const math_Vector& X,Standard_Real& F)
{
gp_XYZ aLoc(X(1), X(2), X(3));
Standard_Real anR2 = X(4)*X(4);
F = 0.;
Standard_Integer i;
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
{
gp_Vec aV(myPoints->Value(i) - aLoc);
Standard_Real aD2 = aV.CrossSquareMagnitude(myDir);
Standard_Real d = aD2 - anR2;
F += d * d;
}
return Standard_True;
}
//=======================================================================
//function : Gradient
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_FuncCylinderLSDist::Gradient(const math_Vector& X,math_Vector& G)
{
gp_XYZ aLoc(X(1), X(2), X(3));
Standard_Real anR = X(4), anR2 = anR * anR;
Standard_Real x = myDir.X(), y = myDir.Y(), z = myDir.Z();
G.Init(0.);
Standard_Integer i;
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
{
gp_Vec aV(myPoints->Value(i) - aLoc);
Standard_Real aD2 = aV.CrossSquareMagnitude(myDir);
Standard_Real d = aD2 - anR2;
Standard_Real Dx0 = 2.*(aV.Z()*x - aV.X()*z)*z
-2.*(aV.X()*y - aV.Y()*x)*y;
Standard_Real Dy0 = -2.*(aV.Y()*z - aV.Z()*y)*z
+2.*(aV.X()*y - aV.Y()*x)*x;
Standard_Real Dz0 = 2.*(aV.Y()*z - aV.Z()*y)*y
-2.*(aV.Z()*x - aV.X()*z)*x;
G(1) += d * Dx0;
G(2) += d * Dy0;
G(3) += d * Dz0;
//
G(4) += d;
}
G *= 2;
G(6) *= -2.*anR;
return Standard_True;
}
//=======================================================================
//function : Values
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_FuncCylinderLSDist::Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
{
gp_XYZ aLoc(X(1), X(2), X(3));
Standard_Real anR = X(4), anR2 = anR * anR;
Standard_Real x = myDir.X(), y = myDir.Y(), z = myDir.Z();
F = 0.;
G.Init(0.);
Standard_Integer i;
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
{
gp_Vec aV(myPoints->Value(i) - aLoc);
Standard_Real aD2 = aV.CrossSquareMagnitude(myDir);
Standard_Real d = aD2 - anR2;
Standard_Real Dx0 = 2.*(aV.Z()*x - aV.X()*z)*z
- 2.*(aV.X()*y - aV.Y()*x)*y;
Standard_Real Dy0 = -2.*(aV.Y()*z - aV.Z()*y)*z
+ 2.*(aV.X()*y - aV.Y()*x)*x;
Standard_Real Dz0 = 2.*(aV.Y()*z - aV.Z()*y)*y
- 2.*(aV.Z()*x - aV.X()*z)*x;
G(1) += d * Dx0;
G(2) += d * Dy0;
G(3) += d * Dz0;
//
G(4) += d;
//
F += d * d;
}
G *= 2;
G(4) *= -2.*anR;
return true;
}

View File

@@ -0,0 +1,100 @@
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2022 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.
#ifndef _GeomConvert_FuncCylinderLSDist_HeaderFile
#define _GeomConvert_FuncCylinderLSDist_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <math_MultipleVarFunctionWithGradient.hxx>
#include <TColgp_HArray1OfXYZ.hxx>
#include <math_Vector.hxx>
#include <gp_Dir.hxx>
//! Function for search of cylinder canonic parameters: coordinates of center local coordinate system,
//! direction of axis and radius from set of points
//! by least square method.
//!
//! The class inherits math_MultipleVarFunctionWithGradient and thus is intended
//! for use in math_BFGS algorithm.
//!
//! Parametrisation:
//! Cylinder is defined by its axis and radius. Axis is defined by 3 cartesian coordinats it location x0, y0, z0
//! and direction, which is constant and set by user:
//! dir.x, dir.y, dir.z
//! The criteria is:
//! F(x0, y0, z0, theta, phi, R) = Sum[|(P(i) - Loc)^dir|^2 - R^2]^2 => min
//! P(i) is i-th sample point, Loc, dir - axis location and direction, R - radius
//!
//! The square vector product |(P(i) - Loc)^dir|^2 is:
//!
//! [(y - y0)*dir.z - (z - z0)*dir.y]^2 +
//! [(z - z0)*dir.x - (x - x0)*dir.z]^2 +
//! [(x - x0)*dir.y - (y - y0)*dir.x]^2
//!
//! First derivative of square vector product are:
//! Dx0 = 2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.z
//! -2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.y
//! Dy0 = -2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.z
//! +2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.x
//! Dz0 = 2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.y
//! -2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.x
//!
//! dF/dx0 : G1(...) = 2*Sum{[...]*Dx0}
//! dF/dy0 : G2(...) = 2*Sum{[...]*Dy0}
//! dF/dz0 : G3(...) = 2*Sum{[...]*Dz0}
//! dF/dR : G4(...) = -4*R*Sum[...]
//! [...] = [|(P(i) - Loc)^dir|^2 - R^2]
class GeomConvert_FuncCylinderLSDist : public math_MultipleVarFunctionWithGradient
{
public:
DEFINE_STANDARD_ALLOC
//! Constructor.
Standard_EXPORT GeomConvert_FuncCylinderLSDist() {};
Standard_EXPORT GeomConvert_FuncCylinderLSDist(const Handle(TColgp_HArray1OfXYZ)& thePoints,
const gp_Dir& theDir);
void SetPoints(const Handle(TColgp_HArray1OfXYZ)& thePoints)
{
myPoints = thePoints;
}
void SetDir(const gp_Dir& theDir)
{
myDir = theDir;
}
//! Number of variables.
Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
//! Value.
Standard_EXPORT Standard_Boolean Value(const math_Vector& X,Standard_Real& F) Standard_OVERRIDE;
//! Gradient.
Standard_EXPORT Standard_Boolean Gradient(const math_Vector& X,math_Vector& G) Standard_OVERRIDE;
//! Value and gradient.
Standard_EXPORT Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G) Standard_OVERRIDE;
private:
Handle(TColgp_HArray1OfXYZ) myPoints;
gp_Dir myDir;
};
#endif // _GeomConvert_FuncCylinderLSDist_HeaderFile

View File

@@ -0,0 +1,115 @@
// Created on: 2016-05-10
// Created by: Alexander MALYSHEV
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2016 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 <GeomConvert_FuncSphereLSDist.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <math_Vector.hxx>
//=======================================================================
//function : GeomConvert_FuncSphereLSDist
//purpose :
//=======================================================================
GeomConvert_FuncSphereLSDist::GeomConvert_FuncSphereLSDist(const Handle(TColgp_HArray1OfXYZ)& thePoints):
myPoints(thePoints)
{
}
//=======================================================================
//function : NbVariables
//purpose :
//=======================================================================
Standard_Integer GeomConvert_FuncSphereLSDist::NbVariables () const
{
return 4;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_FuncSphereLSDist::Value(const math_Vector& X,Standard_Real& F)
{
gp_XYZ aLoc(X(1), X(2), X(3));
Standard_Real anR2 = X(4)*X(4);
F = 0.;
Standard_Integer i;
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
{
Standard_Real d = (myPoints->Value(i) - aLoc).SquareModulus() - anR2;
F += d * d;
}
return Standard_True;
}
//=======================================================================
//function : Gradient
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_FuncSphereLSDist::Gradient(const math_Vector& X,math_Vector& G)
{
gp_XYZ aLoc(X(1), X(2), X(3));
Standard_Real anR = X(4), anR2 = anR * anR;
G.Init(0.);
Standard_Integer i;
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
{
gp_XYZ dLoc = myPoints->Value(i) - aLoc;
Standard_Real d = dLoc.SquareModulus() - anR2;
G(1) += d * dLoc.X();
G(2) += d * dLoc.Y();
G(3) += d * dLoc.Z();
G(4) += d;
}
G *= -4;
G(4) *= anR;
return Standard_True;
}
//=======================================================================
//function : Values
//purpose :
//=======================================================================
Standard_Boolean GeomConvert_FuncSphereLSDist::Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
{
gp_XYZ aLoc(X(1), X(2), X(3));
Standard_Real anR = X(4), anR2 = anR * anR;
G.Init(0.);
F = 0.;
Standard_Integer i;
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
{
gp_XYZ dLoc = myPoints->Value(i) - aLoc;
Standard_Real d = dLoc.SquareModulus() - anR2;
G(1) += d * dLoc.X();
G(2) += d * dLoc.Y();
G(3) += d * dLoc.Z();
G(4) += d;
F += d * d;
}
G *= -4;
G(4) *= anR;
return true;
}

View File

@@ -0,0 +1,77 @@
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2022 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.
#ifndef _GeomConvert_FuncSphereLSDist_HeaderFile
#define _GeomConvert_FuncSphereLSDist_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <math_MultipleVarFunctionWithGradient.hxx>
#include <TColgp_HArray1OfXYZ.hxx>
#include <math_Vector.hxx>
//! Function for search of sphere canonic parameters: coordinates of center and radius from set of moints
//! by least square method.
//! //!
//! The class inherits math_MultipleVarFunctionWithGradient and thus is intended
//! for use in math_BFGS algorithm.
//!
//! The criteria is:
//! F(x0, y0, z0, R) = Sum[(x(i) - x0)^2 + (y(i) - y0)^2 + (z(i) - z0)^2 - R^2]^2 => min,
//! x(i), y(i), z(i) - coordinates of sample points, x0, y0, z0, R - coordinates of center and radius of sphere,
//! which must be defined
//!
//! The first derivative are:
//! dF/dx0 : G1(x0, y0, z0, R) = -4*Sum{[...]*(x(i) - x0)}
//! dF/dy0 : G2(x0, y0, z0, R) = -4*Sum{[...]*(y(i) - y0)}
//! dF/dz0 : G3(x0, y0, z0, R) = -4*Sum{[...]*(z(i) - z0)}
//! dF/dR : G4(x0, y0, z0, R) = -4*R*Sum[...]
//! [...] = [(x(i) - x0)^2 + (y(i) - y0)^2 + (z(i) - z0)^2 - R^2]
//!
class GeomConvert_FuncSphereLSDist : public math_MultipleVarFunctionWithGradient
{
public:
DEFINE_STANDARD_ALLOC
//! Constructor.
Standard_EXPORT GeomConvert_FuncSphereLSDist() {};
Standard_EXPORT GeomConvert_FuncSphereLSDist(const Handle(TColgp_HArray1OfXYZ)& thePoints);
void SetPoints(const Handle(TColgp_HArray1OfXYZ)& thePoints)
{
myPoints = thePoints;
}
//! Number of variables.
Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
//! Value.
Standard_EXPORT Standard_Boolean Value(const math_Vector& X,Standard_Real& F) Standard_OVERRIDE;
//! Gradient.
Standard_EXPORT Standard_Boolean Gradient(const math_Vector& X,math_Vector& G) Standard_OVERRIDE;
//! Value and gradient.
Standard_EXPORT Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G) Standard_OVERRIDE;
private:
Handle(TColgp_HArray1OfXYZ) myPoints;
};
#endif // _GeomConvert_FuncSphereLSDist_HeaderFile

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,135 @@
// Created: 1998-06-03
//
// Copyright (c) 1999-2013 OPEN CASCADE SAS
//
// This file is part of commercial software by OPEN CASCADE SAS,
// furnished in accordance with the terms and conditions of the contract
// and with the inclusion of this copyright notice.
// This file or any part thereof may not be provided or otherwise
// made available to any third party.
//
// No ownership title to the software is transferred hereby.
//
// OPEN CASCADE SAS makes no representation or warranties with respect to the
// performance of this software, and specifically disclaims any responsibility
// for any damages, special or consequential, connected with its use.
#ifndef _GeomConvert_SurfToAnaSurf_HeaderFile
#define _GeomConvert_SurfToAnaSurf_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Real.hxx>
#include <Standard_Boolean.hxx>
#include <GeomConvert_ConvType.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <TColgp_HArray1OfXYZ.hxx>
class Geom_Surface;
class Geom_SurfaceOfRevolution;
class Geom_Circle;
//! Converts a surface to the analitical form with given
//! precision. Conversion is done only the surface is bspline
//! of bezier and this can be approximed by some analytical
//! surface with that precision.
class GeomConvert_SurfToAnaSurf
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT GeomConvert_SurfToAnaSurf();
Standard_EXPORT GeomConvert_SurfToAnaSurf(const Handle(Geom_Surface)& S);
Standard_EXPORT void Init (const Handle(Geom_Surface)& S);
void SetConvType(const GeomConvert_ConvType theConvType = GeomConvert_Simplest)
{
myConvType = theConvType;
}
void SetTarget(const GeomAbs_SurfaceType theSurfType = GeomAbs_Plane)
{
myTarget = theSurfType;
}
//! Returns maximal deviation of converted surface from the original
//! one computed by last call to ConvertToAnalytical
Standard_Real Gap() const
{
return myGap;
}
//! Tries to convert the Surface to an Analytic form
//! Returns the result
//! In case of failure, returns a Null Handle
//!
Standard_EXPORT Handle(Geom_Surface) ConvertToAnalytical (const Standard_Real InitialToler);
Standard_EXPORT Handle(Geom_Surface) ConvertToAnalytical (const Standard_Real InitialToler,
const Standard_Real Umin, const Standard_Real Umax,
const Standard_Real Vmin, const Standard_Real Vmax);
//! Returns true if surfaces is same with the given tolerance
Standard_EXPORT static Standard_Boolean IsSame (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real tol);
//! Returns true, if surface is canonical
Standard_EXPORT static Standard_Boolean IsCanonical (const Handle(Geom_Surface)& S);
private:
//!static method for checking surface of revolution
//!To avoid two-parts cone-like surface
static void CheckVTrimForRevSurf(const Handle(Geom_SurfaceOfRevolution)& aRevSurf,
Standard_Real& V1, Standard_Real& V2);
//!static method to try create cylindrical or conical surface
static Handle(Geom_Surface) TryCylinerCone(const Handle(Geom_Surface)& theSurf, const Standard_Boolean theVCase,
const Handle(Geom_Curve)& theUmidiso, const Handle(Geom_Curve)& theVmidiso,
const Standard_Real theU1, const Standard_Real theU2, const Standard_Real theV1, const Standard_Real theV2,
const Standard_Real theToler);
//!static method to try create cylinrical surface using least square method
static Standard_Boolean GetCylByLS(const Handle(TColgp_HArray1OfXYZ)& thePoints,
const Standard_Real theTol,
gp_Ax3& thePos, Standard_Real& theR,
Standard_Real& theGap);
//!static method to try create cylinrical surface based on its Gauss field
static Handle(Geom_Surface) TryCylinderByGaussField(const Handle(Geom_Surface)& theSurf,
const Standard_Real theU1, const Standard_Real theU2, const Standard_Real theV1, const Standard_Real theV2,
const Standard_Real theToler, const Standard_Integer theNbU = 20, const Standard_Integer theNbV = 20,
const Standard_Boolean theLeastSquare = Standard_False);
//! static method to try create toroidal surface.
//! In case <isTryUMajor> = Standard_True try to use V isoline radius as minor radaius.
static Handle(Geom_Surface) TryTorusSphere(const Handle(Geom_Surface)& theSurf,
const Handle(Geom_Circle)& circle,
const Handle(Geom_Circle)& otherCircle,
const Standard_Real Param1,
const Standard_Real Param2,
const Standard_Real aParam1ToCrv,
const Standard_Real aParam2ToCrv,
const Standard_Real toler,
const Standard_Boolean isTryUMajor);
static Standard_Real ComputeGap(const Handle(Geom_Surface)& theSurf,
const Standard_Real theU1, const Standard_Real theU2, const Standard_Real theV1, const Standard_Real theV2,
const Handle(Geom_Surface) theNewSurf, const Standard_Real theTol = RealLast());
protected:
private:
Handle(Geom_Surface) mySurf;
Standard_Real myGap;
GeomConvert_ConvType myConvType;
GeomAbs_SurfaceType myTarget;
};
#endif // _GeomConvert_SurfToAnaSurf_HeaderFile

View File

@@ -59,7 +59,9 @@
#include <Geom2dConvert.hxx>
#include <Geom2dConvert_BSplineCurveToBezierCurve.hxx>
#include <GeomLProp_SLProps.hxx>
#include <GeomConvert_SurfToAnaSurf.hxx>
#include <GeomConvert_CurveToAnaCurve.hxx>
#include <GeomConvert_ConvType.hxx>
#include <DrawTrSurf_BezierSurface.hxx>
#include <DrawTrSurf_BSplineSurface.hxx>
@@ -522,6 +524,111 @@ static Standard_Integer converting(Draw_Interpretor& , Standard_Integer n, const
return 0;
}
//=======================================================================
//function : converting to canonical
//purpose :
//=======================================================================
static Standard_Integer tocanon(Draw_Interpretor& di, Standard_Integer n, const char ** a)
{
if (n < 3) return 1;
GeomConvert_ConvType aConvType = GeomConvert_Simplest;
GeomAbs_CurveType aCurv = GeomAbs_Line;
GeomAbs_SurfaceType aSurf = GeomAbs_Plane;
if (n > 4)
{
if (strcmp(a[4], "sim") == 0) {
aConvType = GeomConvert_Simplest;
}
else if (strcmp(a[4], "gap") == 0) {
aConvType = GeomConvert_MinGap;
}
else if (strcmp(a[4], "lin") == 0) {
aConvType = GeomConvert_Target;
aCurv = GeomAbs_Line;
}
else if (strcmp(a[4], "cir") == 0) {
aConvType = GeomConvert_Target;
aCurv = GeomAbs_Circle;
}
else if (strcmp(a[4], "ell") == 0) {
aConvType = GeomConvert_Target;
aCurv = GeomAbs_Ellipse;
}
else if (strcmp(a[4], "pln") == 0) {
aConvType = GeomConvert_Target;
aSurf = GeomAbs_Plane;
}
else if (strcmp(a[4], "cyl") == 0) {
aConvType = GeomConvert_Target;
aSurf = GeomAbs_Cylinder;
}
else if (strcmp(a[4], "con") == 0) {
aConvType = GeomConvert_Target;
aSurf = GeomAbs_Cone;
}
else if (strcmp(a[4], "sph") == 0) {
aConvType = GeomConvert_Target;
aSurf = GeomAbs_Sphere;
}
else if (strcmp(a[4], "tor") == 0) {
aConvType = GeomConvert_Target;
aSurf = GeomAbs_Torus;
}
}
Standard_Real tol = Precision::Confusion();
if (n > 3)
{
tol = Draw::Atof(a[3]);
}
Handle(Geom_Curve) GC = DrawTrSurf::GetCurve(a[2]);
if (GC.IsNull()) {
Handle(Geom_Surface) GS = DrawTrSurf::GetSurface(a[2]);
if (GS.IsNull()) {
return 1;
}
else {
GeomConvert_SurfToAnaSurf aSurfToAna(GS);
aSurfToAna.SetConvType(aConvType);
if(aConvType == GeomConvert_Target)
aSurfToAna.SetTarget(aSurf);
Handle(Geom_Surface) anAnaSurf = aSurfToAna.ConvertToAnalytical(tol);
if (!anAnaSurf.IsNull())
{
DrawTrSurf::Set(a[1], anAnaSurf);
Standard_Real aGap = aSurfToAna.Gap();
di << "Gap = " << aGap << "\n";
}
else
di << "Conversion failed" << "\n";
}
}
else {
GeomConvert_CurveToAnaCurve aCurvToAna(GC);
aCurvToAna.SetConvType(aConvType);
if (aConvType == GeomConvert_Target)
aCurvToAna.SetTarget(aCurv);
Handle(Geom_Curve) anAnaCurv;
Standard_Real tf = GC->FirstParameter(), tl = GC->LastParameter(), ntf, ntl;
Standard_Boolean isdone = aCurvToAna.ConvertToAnalytical(tol, anAnaCurv, tf, tl, ntf, ntl);
if (isdone)
{
anAnaCurv = new Geom_TrimmedCurve(anAnaCurv, ntf, ntl);
DrawTrSurf::Set(a[1], anAnaCurv);
Standard_Real aGap = aCurvToAna.Gap();
di << "Gap = " << aGap << "\n";
}
else
di << "Conversion failed" << "\n";
}
return 0;
}
//=======================================================================
//function : tobezier
@@ -543,11 +650,7 @@ static Standard_Integer tobezier(Draw_Interpretor& di,
if ( C3d.IsNull()) {
Handle(Geom_BSplineSurface) S =
DrawTrSurf::GetBSplineSurface(a[2]);
if (S.IsNull())
{
delete[] name;
return 1;
}
if ( S.IsNull()) return 1;
if (n == 7) {
Standard_Real U1, U2, V1, V2;
U1 = Draw::Atof(a[3]);
@@ -635,8 +738,6 @@ static Standard_Integer tobezier(Draw_Interpretor& di,
}
}
delete[] name;
return 0;
}
@@ -1720,6 +1821,11 @@ void GeomliteTest::SurfaceCommands(Draw_Interpretor& theCommands)
__FILE__,
converting,g);
theCommands.Add("tocanon",
"tocanon result c3d/surf [tol [sim gap lin cir ell pln cyl con sph tor]]",
__FILE__,
tocanon, g);
theCommands.Add("tobezier",
"tobezier result c2d/c3d/surf [ufirst, ulast / ufirst, ulast, vfirst, vlast]",
__FILE__,

View File

@@ -23,8 +23,8 @@ enum Graphic3d_DisplayPriority
Graphic3d_DisplayPriority_INVALID = -1,
Graphic3d_DisplayPriority_Bottom = 0,
Graphic3d_DisplayPriority_AlmostBottom = 1,
Graphic3d_DisplayPriority_Below3 = 2,
Graphic3d_DisplayPriority_Below2 = 3,
Graphic3d_DisplayPriority_Below2 = 2,
Graphic3d_DisplayPriority_Below1 = 3,
Graphic3d_DisplayPriority_Below = 4,
Graphic3d_DisplayPriority_Normal = 5,
Graphic3d_DisplayPriority_Above = 6,

View File

@@ -1547,7 +1547,7 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getStdProgramPhong (con
}
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
aProgramSrc->SetPBR (theIsPBR);
aProgramSrc->SetPBR (theIsPBR); // should be set before defaultGlslVersion()
TCollection_AsciiString aSrcVert, aSrcVertExtraFunc, aSrcVertExtraMain;
TCollection_AsciiString aSrcFrag, aSrcFragGetVertColor, aSrcFragExtraMain;
@@ -1987,6 +1987,8 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getPBREnvBakingProgram
{
Standard_ASSERT_RAISE (theIndex >= 0 && theIndex <= 2,"");
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
aProgramSrc->SetPBR (true); // should be set before defaultGlslVersion()
Graphic3d_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
TCollection_AsciiString aSrcVert = TCollection_AsciiString()
@@ -2033,7 +2035,6 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getPBREnvBakingProgram
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbShadowMaps (0);
aProgramSrc->SetNbClipPlanesMax (0);
aProgramSrc->SetPBR (true);
aProgramSrc->AttachShader (Graphic3d_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
aProgramSrc->AttachShader (Graphic3d_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
return aProgramSrc;

View File

@@ -23,7 +23,8 @@ enum Graphic3d_TypeOfBackfacingModel
Graphic3d_TypeOfBackfacingModel_Auto, //!< automatic back face culling enabled for opaque groups with closed flag
//! (e.g. solids, see Graphic3d_Group::IsClosed())
Graphic3d_TypeOfBackfacingModel_DoubleSided, //!< no culling (double-sided shading)
Graphic3d_TypeOfBackfacingModel_BackCulled, //!< back face culling
Graphic3d_TypeOfBackfacingModel_BackCulled, //!< back face culling
Graphic3d_TypeOfBackfacingModel_FrontCulled, //!< front face culling
// old aliases
Graphic3d_TOBM_AUTOMATIC = Graphic3d_TypeOfBackfacingModel_Auto,
Graphic3d_TOBM_FORCE = Graphic3d_TypeOfBackfacingModel_DoubleSided,

View File

@@ -420,8 +420,7 @@ HLRAlgo_PolyInternalData::UpdateLinks (const Standard_Integer ip1,
aSegIndices2->Conex2 = cnx2;
aNodIndices3.NdSg = find;
Standard_Integer iOld,iNew,iTr,skip,ip4;
Standard_Integer itpk[2] = { -1, -1 };
Standard_Integer iOld,iNew,iTr,skip,ip4,itpk[2];
Standard_Integer n1,n2,n3,nOld[3],nNew[3],New[4];
New[0] = cnx1;
New[2] = myNbTData + 1;

View File

@@ -19,7 +19,14 @@
IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
}
//=======================================================================
// function : IGESCAFControl_ConfigurationNode
@@ -48,7 +55,7 @@ IGESCAFControl_ConfigurationNode::IGESCAFControl_ConfigurationNode(const Handle(
//=======================================================================
bool IGESCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.ReadBSplineContinuity = (ReadMode_BSplineContinuity)
theResource->IntegerVal("read.iges.bspline.continuity", InternalParameters.ReadBSplineContinuity, aScope);
@@ -129,7 +136,7 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Common parameters:\n";

View File

@@ -63,7 +63,7 @@ void IGESCAFControl_Provider::initStatic(const Handle(DE_ConfigurationNode)& the
myOldValues.ReadApproxd1 = Interface_Static::IVal("read.iges.bspline.approxd1.mode") == 1;
myOldValues.ReadResourceName = Interface_Static::CVal("read.iges.resource.name");
myOldValues.ReadSequence = Interface_Static::CVal("read.iges.sequence");
myOldValues.ReadFaultyEntities = Interface_Static::IVal("read.iges.faulty.entities");
myOldValues.ReadFaultyEntities = Interface_Static::IVal("read.iges.faulty.entities") == 1;
myOldValues.ReadOnlyVisible = Interface_Static::IVal("read.iges.onlyvisible") == 1;
myOldValues.WriteBRepMode = (IGESCAFControl_ConfigurationNode::WriteMode_BRep)Interface_Static::IVal("write.iges.brep.mode");

View File

@@ -999,8 +999,7 @@ static void TestWLineToRLine(const IntPatch_SequenceOfLine& slinref,
}
// resolve arcs for vertices not having a link to an arc
Standard_Real utst = 0.0;
Standard_Real vtst = 0.0;
Standard_Real utst,vtst;
TColStd_Array1OfReal paramsResolved(1,nbvtx);
TColStd_Array1OfTransient arcsResolved(1,nbvtx);
arcsResolved.Init(Handle(Adaptor2d_Curve2d)());

View File

@@ -2335,7 +2335,7 @@ Standard_Boolean ClassifyLin2d(const Handle(GeomAdaptor_Surface)& theS,
{
Standard_Real xmin, xmax, ymin, ymax, d1, d2, A, B, C;
Standard_Real par[2] = { 0.0, 0.0 };
Standard_Real par[2];
Standard_Integer nbi = 0;
xmin = theS->FirstUParameter();

View File

@@ -232,14 +232,15 @@ Standard_Real LProp_CLProps::Curvature ()
{
Standard_Real N = myDerivArr[0].CrossSquareMagnitude(myDerivArr[1]);
// if d[0] and d[1] are colinear the curvature is null.
Standard_Real t = N/(DD1*DD2);
//Standard_Real t = N/(DD1*DD2);
Standard_Real t = N / DD1 / DD2;
if (t<=Tol)
{
myCurvature = 0.0;
}
else
{
myCurvature = sqrt(N) / (DD1*sqrt(DD1));
myCurvature = sqrt(N) / DD1 / sqrt(DD1);
}
}

View File

@@ -318,7 +318,7 @@ Bnd_Box MeshVS_DataSource::GetBoundingBox() const
const TColStd_PackedMapOfInteger& aNodes = GetAllNodes();
if( aNodes.Extent() )
{
const Standard_Real aCoordsBuf[3] = { 0.0, 0.0, 0.0 };
Standard_Real aCoordsBuf[ 3 ];
TColStd_Array1OfReal aCoords (*aCoordsBuf, 1, 3);
Standard_Integer nbNodes;
MeshVS_EntityType aType;

View File

@@ -625,7 +625,10 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
}
aGroup2->AddPrimitiveArray (aFaceTriangles);
aSGroup->AddPrimitiveArray (anEdgeSegments);
if (anEdgeOn)
{
aSGroup->AddPrimitiveArray (anEdgeSegments);
}
}
}

View File

@@ -108,7 +108,7 @@ void MeshVS_MeshPrsBuilder::BuildNodes ( const Handle(Prs3d_Presentation)& Prs,
Standard_Boolean HasSelectFlag = ( ( DisplayMode & MeshVS_DMF_SelectionPrs ) != 0 );
Standard_Boolean HasHilightFlag = ( ( DisplayMode & MeshVS_DMF_HilightPrs ) != 0 );
const Standard_Real aCoordsBuf[3] = { 0.0, 0.0, 0.0 };
Standard_Real aCoordsBuf[ 3 ];
TColStd_Array1OfReal aCoords( *aCoordsBuf, 1, 3 );
Standard_Integer NbNodes;
MeshVS_EntityType aType;

View File

@@ -15,10 +15,12 @@
;# Liste des toolkits WOK sous forme de full path
;#
proc DataExchange:toolkits { } {
return [list TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES \
TKXCAF TKXDEIGES TKXDESTEP \
TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh]
return [list TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES \
TKXCAF TKXDEIGES TKXDESTEP \
TKXDE TKXDECascade \
TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh]
}
;#
;# Autres UDs a prendre.
;#

View File

@@ -294,7 +294,7 @@ static LONG CallHandler (DWORD theExceptionCode,
&& theExceptionCode != EXCEPTION_NONCONTINUABLE_EXCEPTION)
{
MessageBeep (MB_ICONHAND);
char aMsgBoxBuffer[2048] = { '\0' };
char aMsgBoxBuffer[2048];
strcat_s (aMsgBoxBuffer, sizeof(aMsgBoxBuffer), aBuffer);
if (aStackBuffer != NULL)
{

View File

@@ -237,7 +237,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
myRenderMode (GL_RENDER),
myShadeModel (GL_SMOOTH),
myPolygonMode (GL_FILL),
myToCullBackFaces (false),
myFaceCulling (Graphic3d_TypeOfBackfacingModel_DoubleSided),
myReadBuffer (0),
myDrawBuffers (0, 7),
myDefaultVao (0),
@@ -547,26 +547,35 @@ void OpenGl_Context::SetFrameBufferSRGB (bool theIsFbo, bool theIsFboSRgb)
}
// =======================================================================
// function : SetCullBackFaces
// function : SetFaceCulling
// purpose :
// =======================================================================
void OpenGl_Context::SetCullBackFaces (bool theToEnable)
void OpenGl_Context::SetFaceCulling (Graphic3d_TypeOfBackfacingModel theMode)
{
if (myToCullBackFaces == theToEnable)
if (myFaceCulling == theMode)
{
return;
}
myToCullBackFaces = theToEnable;
if (theToEnable)
if (theMode == Graphic3d_TypeOfBackfacingModel_BackCulled)
{
//glCullFace (GL_BACK); GL_BACK by default
if (myFaceCulling == Graphic3d_TypeOfBackfacingModel_FrontCulled)
{
core11fwd->glCullFace (GL_BACK);
}
core11fwd->glEnable (GL_CULL_FACE);
}
else if (theMode == Graphic3d_TypeOfBackfacingModel_FrontCulled)
{
core11fwd->glCullFace (GL_FRONT);
core11fwd->glEnable (GL_CULL_FACE);
}
else
{
core11fwd->glCullFace (GL_BACK);
core11fwd->glDisable (GL_CULL_FACE);
}
myFaceCulling = theMode;
}
// =======================================================================
@@ -3084,7 +3093,7 @@ void OpenGl_Context::DumpJson (Standard_OStream& theOStream, Standard_Integer th
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRenderMode)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPolygonMode)
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPolygonOffset)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToCullBackFaces)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFaceCulling)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myReadBuffer)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDefaultVao)

View File

@@ -803,10 +803,19 @@ public: //! @name methods to alter or retrieve current state
Standard_EXPORT bool SetSampleAlphaToCoverage (bool theToEnable);
//! Return back face culling state.
bool ToCullBackFaces() const { return myToCullBackFaces; }
Graphic3d_TypeOfBackfacingModel FaceCulling() const { return myFaceCulling; }
//! Enable or disable back face culling (glEnable (GL_CULL_FACE)).
Standard_EXPORT void SetCullBackFaces (bool theToEnable);
Standard_EXPORT void SetFaceCulling (Graphic3d_TypeOfBackfacingModel theMode);
//! Return back face culling state.
bool ToCullBackFaces() const { return myFaceCulling == Graphic3d_TypeOfBackfacingModel_BackCulled; }
//! Enable or disable back face culling (glCullFace() + glEnable(GL_CULL_FACE)).
void SetCullBackFaces (bool theToEnable)
{
SetFaceCulling (theToEnable ? Graphic3d_TypeOfBackfacingModel_BackCulled : Graphic3d_TypeOfBackfacingModel_DoubleSided);
}
//! Fetch OpenGl context state. This class tracks value of several OpenGl
//! state variables. Consulting the cached values is quicker than
@@ -1155,7 +1164,7 @@ private: //! @name fields tracking current state
Standard_Integer myShadeModel; //!< currently used shade model (glShadeModel)
Standard_Integer myPolygonMode; //!< currently used polygon rasterization mode (glPolygonMode)
Graphic3d_PolygonOffset myPolygonOffset; //!< currently applied polygon offset
bool myToCullBackFaces; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE))
Graphic3d_TypeOfBackfacingModel myFaceCulling; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE))
Standard_Integer myReadBuffer; //!< current read buffer
NCollection_Array1<Standard_Integer>
myDrawBuffers; //!< current draw buffers

View File

@@ -1030,10 +1030,9 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
anOutlineProgram->SetUniform (aCtx, anOutlineProgram->GetStateLocation (OpenGl_OCCT_ORTHO_SCALE), anOrthoScale);
aCtx->SetColor4fv (anAspectFace->Aspect()->EdgeColorRGBA());
aCtx->core11fwd->glCullFace (GL_FRONT);
aCtx->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_FrontCulled);
drawArray (theWorkspace, NULL, false);
aCtx->core11fwd->glCullFace (GL_BACK);
aCtx->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_BackCulled);
}
if (isForcedBlend)

View File

@@ -255,27 +255,34 @@ const OpenGl_Aspects* OpenGl_Workspace::SetAspects (const OpenGl_Aspects* theAsp
// =======================================================================
const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects (bool theToBindTextures)
{
bool toSuppressBackFaces = myView->BackfacingModel() == Graphic3d_TypeOfBackfacingModel_BackCulled;
if (myView->BackfacingModel() == Graphic3d_TypeOfBackfacingModel_Auto)
//bool toSuppressBackFaces = myView->BackfacingModel() == Graphic3d_TypeOfBackfacingModel_BackCulled;
Graphic3d_TypeOfBackfacingModel aCullFacesMode = myView->BackfacingModel();
if (aCullFacesMode == Graphic3d_TypeOfBackfacingModel_Auto)
{
toSuppressBackFaces = myAspectsSet->Aspect()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_BackCulled;
if (myAspectsSet->Aspect()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_Auto
&& myToAllowFaceCulling)
aCullFacesMode = myAspectsSet->Aspect()->FaceCulling();
if (aCullFacesMode == Graphic3d_TypeOfBackfacingModel_Auto)
{
toSuppressBackFaces = true;
if (myAspectsSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Blend
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Mask
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_MaskBlend
|| (myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_BlendAuto
&& myAspectsSet->Aspect()->FrontMaterial().Transparency() != 0.0f))
aCullFacesMode = Graphic3d_TypeOfBackfacingModel_DoubleSided;
if (myToAllowFaceCulling)
{
// disable culling in case of translucent shading aspect
toSuppressBackFaces = false;
if (myAspectsSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Blend
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Mask
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_MaskBlend
|| (myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_BlendAuto
&& myAspectsSet->Aspect()->FrontMaterial().Transparency() != 0.0f))
{
// disable culling in case of translucent shading aspect
aCullFacesMode = Graphic3d_TypeOfBackfacingModel_DoubleSided;
}
else
{
aCullFacesMode = Graphic3d_TypeOfBackfacingModel_BackCulled;
}
}
}
}
myGlContext->SetCullBackFaces (toSuppressBackFaces);
myGlContext->SetFaceCulling (aCullFacesMode);
if (myAspectsSet->Aspect() == myAspectsApplied
&& myHighlightStyle == myAspectFaceAppliedWithHL)

View File

@@ -65,6 +65,7 @@
#include <OSD_Timer.hxx>
#include <TDataStd_Name.hxx>
#include <AppCont_Function.hxx>
#include <math_ComputeKronrodPointsAndWeights.hxx>
#include <limits>
@@ -4261,6 +4262,28 @@ static Standard_Integer OCC33009(Draw_Interpretor&, Standard_Integer, const char
return 0;
}
static Standard_Integer OCC33048(Draw_Interpretor&, Standard_Integer, const char**)
{
Standard_Real isOK = true;
try
{
// This method uses raw pointers for memory manipulations and not used in OCCT.
math_ComputeKronrodPointsAndWeights aCalc(125);
isOK = aCalc.IsDone();
}
catch (...)
{
isOK = false;
}
if (isOK)
std::cout << "OK: Kronrod points and weights are calculated successfully." << std::endl;
else
std::cout << "Error: Problem occurred during calculation of Kronrod points and weights." << std::endl;
return 0;
}
//=======================================================================
//function : QACheckBends
//purpose :
@@ -4435,6 +4458,10 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
"Tests the case when",
__FILE__, OCC33009, group);
theCommands.Add("OCC33048",
"Kronrod points and weights calculation",
__FILE__, OCC33048, group);
theCommands.Add("QACheckBends",
"QACheckBends curve [CosMaxAngle [theNbPoints]]",
__FILE__,

View File

@@ -4,6 +4,7 @@ RWGltf_CafWriter.cxx
RWGltf_CafWriter.hxx
RWGltf_ConfigurationNode.cxx
RWGltf_ConfigurationNode.hxx
RWGltf_DracoParameters.hxx
RWGltf_GltfAccessor.hxx
RWGltf_GltfAccessorCompType.hxx
RWGltf_GltfAccessorLayout.hxx

View File

@@ -22,7 +22,7 @@
#include <OSD_FileSystem.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <Poly_Triangulation.hxx>
#include <OSD_Timer.hxx>
#include <RWGltf_GltfAccessorLayout.hxx>
#include <RWGltf_GltfArrayType.hxx>
#include <RWGltf_GltfMaterialMap.hxx>
@@ -44,6 +44,12 @@
#include <RWGltf_GltfOStreamWriter.hxx>
#endif
#ifdef HAVE_DRACO
#include <Standard_WarningsDisable.hxx>
#include <draco/compression/encode.h>
#include <Standard_WarningsRestore.hxx>
#endif
IMPLEMENT_STANDARD_RTTIEXT(RWGltf_CafWriter, Standard_Transient)
namespace
@@ -84,6 +90,84 @@ namespace
{
theStream.write ((const char* )theTri.GetData(), sizeof(theTri));
}
#ifdef HAVE_DRACO
//! Write nodes to Draco mesh
static void writeNodesToDracoMesh (draco::Mesh& theMesh,
const std::vector<Graphic3d_Vec3>& theNodes)
{
if (theNodes.empty())
{
return;
}
draco::PointAttribute anAttr;
anAttr.Init (draco::GeometryAttribute::POSITION, 3, draco::DT_FLOAT32, false, sizeof(float) * 3);
const int anId = theMesh.AddAttribute (anAttr, true, uint32_t(theNodes.size()));
draco::PointAttribute* aPtr = theMesh.attribute (anId);
draco::PointIndex anIndex(0);
for (size_t aNodeInd = 0; aNodeInd < theNodes.size(); ++aNodeInd, ++anIndex)
{
aPtr->SetAttributeValue (aPtr->mapped_index(anIndex), theNodes[aNodeInd].GetData());
}
}
//! Write normals to Draco mesh
static void writeNormalsToDracoMesh (draco::Mesh& theMesh,
const std::vector<Graphic3d_Vec3>& theNormals)
{
if (theNormals.empty())
{
return;
}
draco::PointAttribute anAttr;
anAttr.Init (draco::GeometryAttribute::NORMAL, 3, draco::DT_FLOAT32, false, sizeof(float) * 3);
const int anId = theMesh.AddAttribute (anAttr, true, uint32_t(theNormals.size()));
draco::PointAttribute* aPtr = theMesh.attribute (anId);
draco::PointIndex anIndex(0);
for (size_t aNormInd = 0; aNormInd < theNormals.size(); ++aNormInd, ++anIndex)
{
aPtr->SetAttributeValue (aPtr->mapped_index(anIndex), theNormals[aNormInd].GetData());
}
}
//! Write texture UV coordinates to Draco mesh
static void writeTexCoordsToDracoMesh (draco::Mesh& theMesh,
const std::vector<Graphic3d_Vec2>& theTexCoord)
{
if (theTexCoord.empty())
{
return;
}
draco::PointAttribute anAttr;
anAttr.Init (draco::GeometryAttribute::TEX_COORD, 2, draco::DT_FLOAT32, false, sizeof(float) * 2);
const int anId = theMesh.AddAttribute (anAttr, true, uint32_t(theTexCoord.size()));
draco::PointAttribute* aPtr = theMesh.attribute (anId);
draco::PointIndex anIndex(0);
for (size_t aTexInd = 0; aTexInd < theTexCoord.size(); ++aTexInd, ++anIndex)
{
aPtr->SetAttributeValue (aPtr->mapped_index(anIndex), theTexCoord[aTexInd].GetData());
}
}
//! Write indices to Draco mesh
static void writeIndicesToDracoMesh (draco::Mesh& theMesh,
const std::vector<Poly_Triangle>& theIndices)
{
draco::Mesh::Face aFace;
int anIndex = 0;
for (size_t anInd = 0; anInd < theIndices.size(); ++anInd, ++anIndex)
{
const Poly_Triangle& anElem = theIndices[anInd];
aFace[0] = anElem.Value(1);
aFace[1] = anElem.Value(2);
aFace[2] = anElem.Value(3);
theMesh.SetFace (draco::FaceIndex (anIndex), aFace);
}
}
#endif
}
//================================================================
@@ -150,7 +234,8 @@ Standard_Boolean RWGltf_CafWriter::toSkipFaceMesh (const RWMesh_FaceIterator& th
void RWGltf_CafWriter::saveNodes (RWGltf_GltfFace& theGltfFace,
std::ostream& theBinFile,
const RWMesh_FaceIterator& theFaceIter,
Standard_Integer& theAccessorNb) const
Standard_Integer& theAccessorNb,
const std::shared_ptr<RWGltf_CafWriter::Mesh>& theMesh) const
{
if (theGltfFace.NodePos.Id == RWGltf_GltfAccessor::INVALID_ID)
{
@@ -161,8 +246,11 @@ void RWGltf_CafWriter::saveNodes (RWGltf_GltfFace& theGltfFace,
}
else
{
const int64_t aPos = theGltfFace.NodePos.ByteOffset + myBuffViewPos.ByteOffset + theGltfFace.NodePos.Count * sizeof(Graphic3d_Vec3);
Standard_ASSERT_RAISE (aPos == (int64_t )theBinFile.tellp(), "wrong offset");
if (theMesh.get() == nullptr)
{
const int64_t aPos = theGltfFace.NodePos.ByteOffset + myBuffViewPos.ByteOffset + theGltfFace.NodePos.Count * sizeof(Graphic3d_Vec3);
Standard_ASSERT_RAISE(aPos == (int64_t)theBinFile.tellp(), "wrong offset");
}
}
theGltfFace.NodePos.Count += theFaceIter.NbNodes();
@@ -172,7 +260,14 @@ void RWGltf_CafWriter::saveNodes (RWGltf_GltfFace& theGltfFace,
gp_XYZ aNode = theFaceIter.NodeTransformed (aNodeIter).XYZ();
myCSTrsf.TransformPosition (aNode);
theGltfFace.NodePos.BndBox.Add (Graphic3d_Vec3d(aNode.X(), aNode.Y(), aNode.Z()));
writeVec3 (theBinFile, aNode);
if (theMesh.get() != nullptr)
{
theMesh->NodesVec.push_back(Graphic3d_Vec3(float(aNode.X()), float(aNode.Y()), float(aNode.Z())));
}
else
{
writeVec3(theBinFile, aNode);
}
}
}
@@ -183,7 +278,8 @@ void RWGltf_CafWriter::saveNodes (RWGltf_GltfFace& theGltfFace,
void RWGltf_CafWriter::saveNormals (RWGltf_GltfFace& theGltfFace,
std::ostream& theBinFile,
RWMesh_FaceIterator& theFaceIter,
Standard_Integer& theAccessorNb) const
Standard_Integer& theAccessorNb,
const std::shared_ptr<RWGltf_CafWriter::Mesh>& theMesh) const
{
if (!theFaceIter.HasNormals())
{
@@ -199,8 +295,11 @@ void RWGltf_CafWriter::saveNormals (RWGltf_GltfFace& theGltfFace,
}
else
{
const int64_t aPos = theGltfFace.NodeNorm.ByteOffset + myBuffViewNorm.ByteOffset + theGltfFace.NodeNorm.Count * sizeof(Graphic3d_Vec3);
Standard_ASSERT_RAISE (aPos == (int64_t )theBinFile.tellp(), "wrong offset");
if (theMesh.get() == nullptr)
{
const int64_t aPos = theGltfFace.NodeNorm.ByteOffset + myBuffViewNorm.ByteOffset + theGltfFace.NodeNorm.Count * sizeof(Graphic3d_Vec3);
Standard_ASSERT_RAISE(aPos == (int64_t)theBinFile.tellp(), "wrong offset");
}
}
theGltfFace.NodeNorm.Count += theFaceIter.NbNodes();
@@ -210,7 +309,14 @@ void RWGltf_CafWriter::saveNormals (RWGltf_GltfFace& theGltfFace,
const gp_Dir aNormal = theFaceIter.NormalTransformed (aNodeIter);
Graphic3d_Vec3 aVecNormal ((float )aNormal.X(), (float )aNormal.Y(), (float )aNormal.Z());
myCSTrsf.TransformNormal (aVecNormal);
writeVec3 (theBinFile, aVecNormal);
if (theMesh.get() != nullptr)
{
theMesh->NormalsVec.push_back(aVecNormal);
}
else
{
writeVec3(theBinFile, aVecNormal);
}
}
}
@@ -221,7 +327,8 @@ void RWGltf_CafWriter::saveNormals (RWGltf_GltfFace& theGltfFace,
void RWGltf_CafWriter::saveTextCoords (RWGltf_GltfFace& theGltfFace,
std::ostream& theBinFile,
const RWMesh_FaceIterator& theFaceIter,
Standard_Integer& theAccessorNb) const
Standard_Integer& theAccessorNb,
const std::shared_ptr<RWGltf_CafWriter::Mesh>& theMesh) const
{
if (!theFaceIter.HasTexCoords())
{
@@ -253,8 +360,11 @@ void RWGltf_CafWriter::saveTextCoords (RWGltf_GltfFace& theGltfFace,
}
else
{
const int64_t aPos = theGltfFace.NodeUV.ByteOffset + myBuffViewTextCoord.ByteOffset + theGltfFace.NodeUV.Count * sizeof(Graphic3d_Vec2);
Standard_ASSERT_RAISE (aPos == (int64_t )theBinFile.tellp(), "wrong offset");
if (theMesh.get() == nullptr)
{
const int64_t aPos = theGltfFace.NodeUV.ByteOffset + myBuffViewTextCoord.ByteOffset + theGltfFace.NodeUV.Count * sizeof(Graphic3d_Vec2);
Standard_ASSERT_RAISE(aPos == (int64_t)theBinFile.tellp(), "wrong offset");
}
}
theGltfFace.NodeUV.Count += theFaceIter.NbNodes();
@@ -263,7 +373,14 @@ void RWGltf_CafWriter::saveTextCoords (RWGltf_GltfFace& theGltfFace,
{
gp_Pnt2d aTexCoord = theFaceIter.NodeTexCoord (aNodeIter);
aTexCoord.SetY (1.0 - aTexCoord.Y());
writeVec2 (theBinFile, aTexCoord.XY());
if (theMesh.get() != nullptr)
{
theMesh->TexCoordsVec.push_back(Graphic3d_Vec2((float)aTexCoord.X(), (float)aTexCoord.Y()));
}
else
{
writeVec2(theBinFile, aTexCoord.XY());
}
}
}
@@ -274,7 +391,8 @@ void RWGltf_CafWriter::saveTextCoords (RWGltf_GltfFace& theGltfFace,
void RWGltf_CafWriter::saveIndices (RWGltf_GltfFace& theGltfFace,
std::ostream& theBinFile,
const RWMesh_FaceIterator& theFaceIter,
Standard_Integer& theAccessorNb)
Standard_Integer& theAccessorNb,
const std::shared_ptr<RWGltf_CafWriter::Mesh>& theMesh)
{
if (theGltfFace.Indices.Id == RWGltf_GltfAccessor::INVALID_ID)
{
@@ -287,11 +405,14 @@ void RWGltf_CafWriter::saveIndices (RWGltf_GltfFace& theGltfFace,
}
else
{
const int64_t aRefPos = (int64_t )theBinFile.tellp();
const int64_t aPos = theGltfFace.Indices.ByteOffset
+ myBuffViewInd.ByteOffset
+ theGltfFace.Indices.Count * (theGltfFace.Indices.ComponentType == RWGltf_GltfAccessorCompType_UInt32 ? sizeof(uint32_t) : sizeof(uint16_t));
Standard_ASSERT_RAISE (aPos == aRefPos, "wrong offset");
if (theMesh.get() == nullptr)
{
const int64_t aRefPos = (int64_t )theBinFile.tellp();
const int64_t aPos = theGltfFace.Indices.ByteOffset
+ myBuffViewInd.ByteOffset
+ theGltfFace.Indices.Count * (theGltfFace.Indices.ComponentType == RWGltf_GltfAccessorCompType_UInt32 ? sizeof(uint32_t) : sizeof(uint16_t));
Standard_ASSERT_RAISE (aPos == aRefPos, "wrong offset");
}
}
const Standard_Integer aNodeFirst = theGltfFace.NbIndexedNodes - theFaceIter.ElemLower();
@@ -306,13 +427,20 @@ void RWGltf_CafWriter::saveIndices (RWGltf_GltfFace& theGltfFace,
aTri(1) += aNodeFirst;
aTri(2) += aNodeFirst;
aTri(3) += aNodeFirst;
if (theGltfFace.Indices.ComponentType == RWGltf_GltfAccessorCompType_UInt16)
if (theMesh.get() != nullptr)
{
writeTriangle16 (theBinFile, NCollection_Vec3<uint16_t>((uint16_t)aTri(1), (uint16_t)aTri(2), (uint16_t)aTri(3)));
theMesh->IndicesVec.push_back(aTri);
}
else
{
writeTriangle32 (theBinFile, Graphic3d_Vec3i (aTri(1), aTri(2), aTri(3)));
if (theGltfFace.Indices.ComponentType == RWGltf_GltfAccessorCompType_UInt16)
{
writeTriangle16(theBinFile, NCollection_Vec3<uint16_t>((uint16_t)aTri(1), (uint16_t)aTri(2), (uint16_t)aTri(3)));
}
else
{
writeTriangle32(theBinFile, Graphic3d_Vec3i(aTri(1), aTri(2), aTri(3)));
}
}
}
}
@@ -373,6 +501,14 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
const TColStd_MapOfAsciiString* theLabelFilter,
const Message_ProgressRange& theProgress)
{
#ifndef HAVE_DRACO
if (myDracoParameters.DracoCompression)
{
Message::SendFail ("Error: cannot use Draco compression, Draco library missing.");
return false;
}
#endif
myBuffViewPos.Id = RWGltf_GltfAccessor::INVALID_ID;
myBuffViewPos.ByteOffset = 0;
myBuffViewPos.ByteLength = 0;
@@ -396,6 +532,8 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
myBuffViewInd.ByteLength = 0;
myBuffViewInd.Target = RWGltf_GltfBufferViewTarget_ELEMENT_ARRAY_BUFFER;
myBuffViewsDraco.clear();
myBinDataMap.Clear();
myBinDataLen64 = 0;
@@ -508,6 +646,7 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
}
}
std::vector<std::shared_ptr<RWGltf_CafWriter::Mesh>> aMeshes;
Standard_Integer aNbAccessors = 0;
NCollection_Map<Handle(RWGltf_GltfFaceList)> aWrittenFaces;
NCollection_DataMap<TopoDS_Shape, Handle(RWGltf_GltfFace), TopTools_ShapeMapHasher> aWrittenPrimData;
@@ -526,6 +665,7 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
aBuffView->ByteOffset = aBinFile->tellp();
aWrittenFaces.Clear (false);
aWrittenPrimData.Clear (false);
size_t aMeshIndex = 0;
for (ShapeToGltfFaceMap::Iterator aBinDataIter (myBinDataMap); aBinDataIter.More() && aPSentryBin.More(); aBinDataIter.Next())
{
const Handle(RWGltf_GltfFaceList)& aGltfFaceList = aBinDataIter.Value();
@@ -533,6 +673,23 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
{
continue;
}
std::shared_ptr<RWGltf_CafWriter::Mesh> aMeshPtr;
++aMeshIndex;
#ifdef HAVE_DRACO
if (myDracoParameters.DracoCompression)
{
if (aMeshIndex <= aMeshes.size())
{
aMeshPtr = aMeshes.at(aMeshIndex - 1);
}
else
{
aMeshes.push_back(std::make_shared<RWGltf_CafWriter::Mesh>(RWGltf_CafWriter::Mesh()));
aMeshPtr = aMeshes.back();
}
}
#endif
for (RWGltf_GltfFaceList::Iterator aGltfFaceIter (*aGltfFaceList); aGltfFaceIter.More() && aPSentryBin.More(); aGltfFaceIter.Next())
{
@@ -579,22 +736,22 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
case RWGltf_GltfArrayType_Position:
{
aGltfFace->NbIndexedNodes = 0; // reset to zero before RWGltf_GltfArrayType_Indices step
saveNodes (*aGltfFace, *aBinFile, aFaceIter, aNbAccessors);
saveNodes (*aGltfFace, *aBinFile, aFaceIter, aNbAccessors, aMeshPtr);
break;
}
case RWGltf_GltfArrayType_Normal:
{
saveNormals (*aGltfFace, *aBinFile, aFaceIter, aNbAccessors);
saveNormals (*aGltfFace, *aBinFile, aFaceIter, aNbAccessors, aMeshPtr);
break;
}
case RWGltf_GltfArrayType_TCoord0:
{
saveTextCoords (*aGltfFace, *aBinFile, aFaceIter, aNbAccessors);
saveTextCoords (*aGltfFace, *aBinFile, aFaceIter, aNbAccessors, aMeshPtr);
break;
}
case RWGltf_GltfArrayType_Indices:
{
saveIndices (*aGltfFace, *aBinFile, aFaceIter, aNbAccessors);
saveIndices (*aGltfFace, *aBinFile, aFaceIter, aNbAccessors, aMeshPtr);
break;
}
default:
@@ -611,16 +768,22 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
}
// add alignment by 4 bytes (might happen on RWGltf_GltfAccessorCompType_UInt16 indices)
int64_t aContentLen64 = (int64_t)aBinFile->tellp();
while (aContentLen64 % 4 != 0)
if (!myDracoParameters.DracoCompression)
{
aBinFile->write (" ", 1);
++aContentLen64;
int64_t aContentLen64 = (int64_t)aBinFile->tellp();
while (aContentLen64 % 4 != 0)
{
aBinFile->write(" ", 1);
++aContentLen64;
}
}
}
}
aBuffView->ByteLength = (int64_t )aBinFile->tellp() - aBuffView->ByteOffset;
if (!myDracoParameters.DracoCompression)
{
aBuffView->ByteLength = (int64_t)aBinFile->tellp() - aBuffView->ByteOffset;
}
if (!aPSentryBin.More())
{
return false;
@@ -629,6 +792,72 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
aPSentryBin.Next();
}
if (myDracoParameters.DracoCompression)
{
#ifdef HAVE_DRACO
OSD_Timer aDracoTimer;
aDracoTimer.Start();
int aBuffId = 0;
draco::Encoder aDracoEncoder;
aDracoEncoder.SetAttributeQuantization (draco::GeometryAttribute::POSITION, myDracoParameters.QuantizePositionBits);
aDracoEncoder.SetAttributeQuantization (draco::GeometryAttribute::NORMAL, myDracoParameters.QuantizeNormalBits);
aDracoEncoder.SetAttributeQuantization (draco::GeometryAttribute::TEX_COORD, myDracoParameters.QuantizeTexcoordBits);
aDracoEncoder.SetAttributeQuantization (draco::GeometryAttribute::COLOR, myDracoParameters.QuantizeColorBits);
aDracoEncoder.SetAttributeQuantization (draco::GeometryAttribute::GENERIC, myDracoParameters.QuantizeGenericBits);
aDracoEncoder.SetSpeedOptions (myDracoParameters.CompressionLevel, myDracoParameters.CompressionLevel);
for (size_t aMeshInd = 0; aMeshInd != aMeshes.size(); ++aMeshInd)
{
const std::shared_ptr<RWGltf_CafWriter::Mesh>& aCurrentMesh = aMeshes[aMeshInd];
if (aCurrentMesh->NodesVec.empty())
{
continue;
}
draco::Mesh aDracoMesh;
writeNodesToDracoMesh (aDracoMesh, aCurrentMesh->NodesVec);
if (!aCurrentMesh->NormalsVec.empty())
{
writeNormalsToDracoMesh (aDracoMesh, aCurrentMesh->NormalsVec);
}
if (!aCurrentMesh->TexCoordsVec.empty())
{
writeTexCoordsToDracoMesh (aDracoMesh, aCurrentMesh->TexCoordsVec);
}
writeIndicesToDracoMesh (aDracoMesh, aCurrentMesh->IndicesVec);
draco::EncoderBuffer anEncoderBuff;
draco::Status aStatus = aDracoEncoder.EncodeMeshToBuffer (aDracoMesh, &anEncoderBuff);
if (!aStatus.ok())
{
Message::SendFail (TCollection_AsciiString("Error: mesh cannot be encoded in draco buffer."));
return false;
}
RWGltf_GltfBufferView aBuffViewDraco;
aBuffViewDraco.Id = aBuffId++;
aBuffViewDraco.ByteOffset = aBinFile->tellp();
aBinFile->write (anEncoderBuff.data(), std::streamsize(anEncoderBuff.size()));
if (!aBinFile->good())
{
Message::SendFail (TCollection_AsciiString("File '") + myBinFileNameFull + "' cannot be written");
return false;
}
int64_t aLength = (int64_t)aBinFile->tellp();
while (aLength % 4 != 0)
{
aBinFile->write(" ", 1);
++aLength;
}
aBuffViewDraco.ByteLength = aLength - aBuffViewDraco.ByteOffset;
myBuffViewsDraco.push_back (aBuffViewDraco);
}
aDracoTimer.Stop();
Message::SendInfo (TCollection_AsciiString("Draco compression time: ") + aDracoTimer.ElapsedTime() + " s");
#endif
}
if (myIsBinary
&& myToEmbedTexturesInGlb)
{
@@ -1020,10 +1249,13 @@ void RWGltf_CafWriter::writePositions (const RWGltf_GltfFace& theGltfFace)
}
myWriter->StartObject();
myWriter->Key ("bufferView");
myWriter->Int (myBuffViewPos.Id);
myWriter->Key ("byteOffset");
myWriter->Int64 (theGltfFace.NodePos.ByteOffset);
if (!myDracoParameters.DracoCompression)
{
myWriter->Key ("bufferView");
myWriter->Int (myBuffViewPos.Id);
myWriter->Key ("byteOffset");
myWriter->Int64 (theGltfFace.NodePos.ByteOffset);
}
myWriter->Key ("componentType");
myWriter->Int (theGltfFace.NodePos.ComponentType);
myWriter->Key ("count");
@@ -1068,10 +1300,13 @@ void RWGltf_CafWriter::writeNormals (const RWGltf_GltfFace& theGltfFace)
}
myWriter->StartObject();
myWriter->Key ("bufferView");
myWriter->Int (myBuffViewNorm.Id);
myWriter->Key ("byteOffset");
myWriter->Int64 (theGltfFace.NodeNorm.ByteOffset);
if (!myDracoParameters.DracoCompression)
{
myWriter->Key ("bufferView");
myWriter->Int (myBuffViewNorm.Id);
myWriter->Key ("byteOffset");
myWriter->Int64 (theGltfFace.NodeNorm.ByteOffset);
}
myWriter->Key ("componentType");
myWriter->Int (theGltfFace.NodeNorm.ComponentType);
myWriter->Key ("count");
@@ -1116,10 +1351,13 @@ void RWGltf_CafWriter::writeTextCoords (const RWGltf_GltfFace& theGltfFace)
}
myWriter->StartObject();
myWriter->Key ("bufferView");
myWriter->Int (myBuffViewTextCoord.Id);
myWriter->Key ("byteOffset");
myWriter->Int64 (theGltfFace.NodeUV.ByteOffset);
if (!myDracoParameters.DracoCompression)
{
myWriter->Key ("bufferView");
myWriter->Int (myBuffViewTextCoord.Id);
myWriter->Key ("byteOffset");
myWriter->Int64 (theGltfFace.NodeUV.ByteOffset);
}
myWriter->Key ("componentType");
myWriter->Int (theGltfFace.NodeUV.ComponentType);
myWriter->Key ("count");
@@ -1164,10 +1402,13 @@ void RWGltf_CafWriter::writeIndices (const RWGltf_GltfFace& theGltfFace)
}
myWriter->StartObject();
myWriter->Key ("bufferView");
myWriter->Int (myBuffViewInd.Id);
myWriter->Key ("byteOffset");
myWriter->Int64 (theGltfFace.Indices.ByteOffset);
if (!myDracoParameters.DracoCompression)
{
myWriter->Key("bufferView");
myWriter->Int(myBuffViewInd.Id);
myWriter->Key("byteOffset");
myWriter->Int64(theGltfFace.Indices.ByteOffset);
}
myWriter->Key ("componentType");
myWriter->Int (theGltfFace.Indices.ComponentType);
myWriter->Key ("count");
@@ -1309,6 +1550,24 @@ void RWGltf_CafWriter::writeBufferViews (const Standard_Integer theBinDataBuffer
myWriter->Int (myBuffViewInd.Target);
myWriter->EndObject();
}
if (myDracoParameters.DracoCompression)
{
for (size_t aBufInd = 0; aBufInd != myBuffViewsDraco.size(); ++aBufInd)
{
if (myBuffViewsDraco[aBufInd].Id != RWGltf_GltfAccessor::INVALID_ID)
{
aBuffViewId++;
myWriter->StartObject();
myWriter->Key("buffer");
myWriter->Int(theBinDataBufferId);
myWriter->Key("byteLength");
myWriter->Int64(myBuffViewsDraco[aBufInd].ByteLength);
myWriter->Key("byteOffset");
myWriter->Int64(myBuffViewsDraco[aBufInd].ByteOffset);
myWriter->EndObject();
}
}
}
myMaterialMap->FlushGlbBufferViews (myWriter.get(), theBinDataBufferId, aBuffViewId);
@@ -1352,7 +1611,28 @@ void RWGltf_CafWriter::writeBuffers()
// =======================================================================
void RWGltf_CafWriter::writeExtensions()
{
#ifdef HAVE_RAPIDJSON
Standard_ProgramError_Raise_if (myWriter.get() == NULL, "Internal error: RWGltf_CafWriter::writeExtensions()");
if (myDracoParameters.DracoCompression)
{
myWriter->Key(RWGltf_GltfRootElementName(RWGltf_GltfRootElement_ExtensionsUsed));
myWriter->StartArray();
{
myWriter->Key("KHR_draco_mesh_compression");
}
myWriter->EndArray();
myWriter->Key(RWGltf_GltfRootElementName(RWGltf_GltfRootElement_ExtensionsRequired));
myWriter->StartArray();
{
myWriter->Key("KHR_draco_mesh_compression");
}
myWriter->EndArray();
}
#endif
}
// =======================================================================
@@ -1425,6 +1705,7 @@ void RWGltf_CafWriter::writeMaterials (const RWGltf_GltfSceneNodeMap& theSceneNo
// =======================================================================
void RWGltf_CafWriter::writePrimArray (const RWGltf_GltfFace& theGltfFace,
const TCollection_AsciiString& theName,
const int theDracoBufInd,
bool& theToStartPrims)
{
#ifdef HAVE_RAPIDJSON
@@ -1471,12 +1752,48 @@ void RWGltf_CafWriter::writePrimArray (const RWGltf_GltfFace& theGltfFace,
}
myWriter->Key ("mode");
myWriter->Int (RWGltf_GltfPrimitiveMode_Triangles);
if (myDracoParameters.DracoCompression)
{
myWriter->Key("extensions");
myWriter->StartObject();
{
myWriter->Key("KHR_draco_mesh_compression");
myWriter->StartObject();
myWriter->Key("bufferView");
myWriter->Int(myBuffViewsDraco[theDracoBufInd].Id);
myWriter->Key("attributes");
myWriter->StartObject();
{
int anAttrInd = 0;
if (theGltfFace.NodePos.Id != RWGltf_GltfAccessor::INVALID_ID)
{
myWriter->Key("POSITION");
myWriter->Int(anAttrInd++);
}
if (theGltfFace.NodeNorm.Id != RWGltf_GltfAccessor::INVALID_ID)
{
myWriter->Key("NORMAL");
myWriter->Int(anAttrInd++);
}
if (theGltfFace.NodeUV.Id != RWGltf_GltfAccessor::INVALID_ID)
{
myWriter->Key("TEXCOORD_0");
myWriter->Int(anAttrInd++);
}
}
myWriter->EndObject();
myWriter->EndObject();
}
myWriter->EndObject();
}
}
myWriter->EndObject();
#else
(void )theGltfFace;
(void )theName;
(void )theToStartPrims;
(void )theDracoBufInd;
#endif
}
@@ -1492,6 +1809,8 @@ void RWGltf_CafWriter::writeMeshes (const RWGltf_GltfSceneNodeMap& theSceneNodeM
myWriter->Key (RWGltf_GltfRootElementName (RWGltf_GltfRootElement_Meshes));
myWriter->StartArray();
int aDracoBufInd = 0;
NCollection_IndexedDataMap<int, int> aDracoBufIndMap;
NCollection_Map<Handle(RWGltf_GltfFaceList)> aWrittenFaces;
for (RWGltf_GltfSceneNodeMap::Iterator aSceneNodeIter (theSceneNodeMap); aSceneNodeIter.More(); aSceneNodeIter.Next())
{
@@ -1522,7 +1841,23 @@ void RWGltf_CafWriter::writeMeshes (const RWGltf_GltfSceneNodeMap& theSceneNodeM
for (RWGltf_GltfFaceList::Iterator aFaceGroupIter (*aGltfFaceList); aFaceGroupIter.More(); aFaceGroupIter.Next())
{
const Handle(RWGltf_GltfFace)& aGltfFace = aFaceGroupIter.Value();
writePrimArray (*aGltfFace, aNodeName, toStartPrims);
const int aPrevSize = aDracoBufIndMap.Size();
const int aTempDracoBufInd = aDracoBufInd;
if (myDracoParameters.DracoCompression
&& !aDracoBufIndMap.FindFromKey (aGltfFace->NodePos.Id, aDracoBufInd))
{
aDracoBufIndMap.Add (aGltfFace->NodePos.Id, aDracoBufInd);
}
writePrimArray (*aGltfFace, aNodeName, aDracoBufInd, toStartPrims);
if (aTempDracoBufInd != aDracoBufInd)
{
aDracoBufInd = aTempDracoBufInd;
}
if (!myDracoParameters.DracoCompression || aDracoBufIndMap.Size() > aPrevSize)
{
++aDracoBufInd;
}
}
}
else
@@ -1542,7 +1877,23 @@ void RWGltf_CafWriter::writeMeshes (const RWGltf_GltfSceneNodeMap& theSceneNodeM
}
const Handle(RWGltf_GltfFace)& aGltfFace = aGltfFaceList->First();
writePrimArray (*aGltfFace, aNodeName, toStartPrims);
const int aPrevSize = aDracoBufIndMap.Size();
const int aTempDracoBufInd = aDracoBufInd;
if (myDracoParameters.DracoCompression
&& !aDracoBufIndMap.FindFromKey(aGltfFace->NodePos.Id, aDracoBufInd))
{
aDracoBufIndMap.Add(aGltfFace->NodePos.Id, aDracoBufInd);
}
writePrimArray (*aGltfFace, aNodeName, aDracoBufInd, toStartPrims);
if (aTempDracoBufInd != aDracoBufInd)
{
aDracoBufInd = aTempDracoBufInd;
}
if (!myDracoParameters.DracoCompression || aDracoBufIndMap.Size() > aPrevSize)
{
++aDracoBufInd;
}
}
}

View File

@@ -18,12 +18,14 @@
#include <TColStd_MapOfAsciiString.hxx>
#include <TDF_LabelSequence.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <RWGltf_DracoParameters.hxx>
#include <RWGltf_GltfBufferView.hxx>
#include <RWGltf_GltfFace.hxx>
#include <RWGltf_WriterTrsfFormat.hxx>
#include <RWMesh_CoordinateSystemConverter.hxx>
#include <RWMesh_NameFormat.hxx>
#include <XCAFPrs_Style.hxx>
#include <Poly_Triangle.hxx>
#include <memory>
@@ -40,6 +42,15 @@ class RWGltf_CafWriter : public Standard_Transient
DEFINE_STANDARD_RTTIEXT(RWGltf_CafWriter, Standard_Transient)
public:
//! Mesh
struct Mesh
{
std::vector<Graphic3d_Vec3> NodesVec; //!< vector for mesh nodes
std::vector<Graphic3d_Vec3> NormalsVec; //!< vector for mesh normals
std::vector<Graphic3d_Vec2> TexCoordsVec; //!< vector for mesh texture UV coordinates
std::vector<Poly_Triangle> IndicesVec; //!< vector for mesh indices
};
//! Main constructor.
//! @param theFile [in] path to output glTF file
//! @param theIsBinary [in] flag to write into binary glTF format (.glb)
@@ -114,6 +125,12 @@ public:
//! May reduce binary data size thanks to smaller triangle indexes.
void SetSplitIndices16 (bool theToSplit) { myToSplitIndices16 = theToSplit; }
//! Return Draco parameters
const RWGltf_DracoParameters& CompressionParameters() const { return myDracoParameters; }
//! Set Draco parameters
void SetCompressionParameters(const RWGltf_DracoParameters& theDracoParameters) { myDracoParameters = theDracoParameters; }
//! Write glTF file and associated binary file.
//! Triangulation data should be precomputed within shapes!
//! @param theDocument [in] input document
@@ -186,40 +203,48 @@ protected:
//! @param theBinFile [out] output file to write into
//! @param theFaceIter [in] current face to write
//! @param theAccessorNb [in] [out] last accessor index
//! @param theMesh [in] [out] mesh
Standard_EXPORT virtual void saveNodes (RWGltf_GltfFace& theGltfFace,
std::ostream& theBinFile,
const RWMesh_FaceIterator& theFaceIter,
Standard_Integer& theAccessorNb) const;
Standard_Integer& theAccessorNb,
const std::shared_ptr<RWGltf_CafWriter::Mesh>& theMesh) const;
//! Write mesh normals into binary file.
//! @param theGltfFace [out] glTF face definition
//! @param theBinFile [out] output file to write into
//! @param theFaceIter [in] current face to write
//! @param theAccessorNb [in] [out] last accessor index
//! @param theMesh [in] [out] mesh
Standard_EXPORT virtual void saveNormals (RWGltf_GltfFace& theGltfFace,
std::ostream& theBinFile,
RWMesh_FaceIterator& theFaceIter,
Standard_Integer& theAccessorNb) const;
Standard_Integer& theAccessorNb,
const std::shared_ptr<RWGltf_CafWriter::Mesh>& theMesh) const;
//! Write mesh texture UV coordinates into binary file.
//! @param theGltfFace [out] glTF face definition
//! @param theBinFile [out] output file to write into
//! @param theFaceIter [in] current face to write
//! @param theAccessorNb [in] [out] last accessor index
//! @param theMesh [in] [out] mesh
Standard_EXPORT virtual void saveTextCoords (RWGltf_GltfFace& theGltfFace,
std::ostream& theBinFile,
const RWMesh_FaceIterator& theFaceIter,
Standard_Integer& theAccessorNb) const;
Standard_Integer& theAccessorNb,
const std::shared_ptr<RWGltf_CafWriter::Mesh>& theMesh) const;
//! Write mesh indexes into binary file.
//! @param theGltfFace [out] glTF face definition
//! @param theBinFile [out] output file to write into
//! @param theFaceIter [in] current face to write
//! @param theAccessorNb [in] [out] last accessor index
//! @param theMesh [in] [out] mesh
Standard_EXPORT virtual void saveIndices (RWGltf_GltfFace& theGltfFace,
std::ostream& theBinFile,
const RWMesh_FaceIterator& theFaceIter,
Standard_Integer& theAccessorNb);
Standard_Integer& theAccessorNb,
const std::shared_ptr<RWGltf_CafWriter::Mesh>& theMesh);
protected:
@@ -280,9 +305,11 @@ protected:
//! Write a primitive array to RWGltf_GltfRootElement_Meshes section.
//! @param[in] theGltfFace face to write
//! @param[in] theName primitive array name
//! @param[in] theDracoBufInd draco buffer index
//! @param[in,out] theToStartPrims flag indicating that primitive array has been started
Standard_EXPORT virtual void writePrimArray (const RWGltf_GltfFace& theGltfFace,
const TCollection_AsciiString& theName,
const int theDracoBufInd,
bool& theToStartPrims);
//! Write RWGltf_GltfRootElement_Nodes section.
@@ -369,6 +396,8 @@ protected:
ShapeToGltfFaceMap myBinDataMap; //!< map for TopoDS_Face to glTF face (merging duplicates)
int64_t myBinDataLen64; //!< length of binary file
std::vector<RWGltf_GltfBufferView> myBuffViewsDraco; //!< vector of buffers view with compression data
RWGltf_DracoParameters myDracoParameters; //!< Draco parameters
};
#endif // _RWGltf_CafWriter_HeaderFiler

View File

@@ -18,7 +18,14 @@
IMPLEMENT_STANDARD_RTTIEXT(RWGltf_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
}
//=======================================================================
// function : RWGltf_ConfigurationNode
@@ -47,7 +54,7 @@ RWGltf_ConfigurationNode::RWGltf_ConfigurationNode(const Handle(RWGltf_Configura
//=======================================================================
bool RWGltf_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.FileLengthUnit =
theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
@@ -114,7 +121,7 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Common parameters:\n";

View File

@@ -0,0 +1,41 @@
// Copyright (c) 2022 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.
#ifndef _RWGltf_DracoParameters_HeaderFile
#define _RWGltf_DracoParameters_HeaderFile
//! Draco compression parameters
struct RWGltf_DracoParameters
{
RWGltf_DracoParameters()
: DracoCompression (false),
CompressionLevel (7),
QuantizePositionBits (14),
QuantizeNormalBits (10),
QuantizeTexcoordBits (12),
QuantizeColorBits (8),
QuantizeGenericBits (12),
UnifiedQuantization (false)
{}
bool DracoCompression; //!< flag to use Draco compression (FALSE by default). If it is TRUE, compression is used
int CompressionLevel; //!< Draco compression level [0-10] (7 by default)
int QuantizePositionBits; //!< quantization bits for position attribute (14 by default)
int QuantizeNormalBits; //!< quantization bits for normal attribute (10 by default)
int QuantizeTexcoordBits; //!< quantization bits for texture coordinate attribute (12 by default)
int QuantizeColorBits; //!< quantization bits for color attributes (8 by default)
int QuantizeGenericBits; //!< quantization bits for skinning and custom attributes (12 by default)
bool UnifiedQuantization; //!< quantize positions of all primitives using the same quantization grid (FALSE by default)
};
#endif

View File

@@ -493,7 +493,8 @@ void RWGltf_GltfMaterialMap::DefineMaterial (const XCAFPrs_Style& theStyle,
// as both may share the same material having "auto" flag
if (theStyle.Material().IsNull()
|| theStyle.Material()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_Auto
|| theStyle.Material()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_DoubleSided)
|| theStyle.Material()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_DoubleSided
|| theStyle.Material()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_FrontCulled) // front culling flag cannot be exported to glTF
{
myWriter->Key ("doubleSided");
myWriter->Bool (true);

View File

@@ -18,7 +18,14 @@
IMPLEMENT_STANDARD_RTTIEXT(RWObj_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
}
//=======================================================================
// function : RWObj_ConfigurationNode
@@ -47,7 +54,7 @@ RWObj_ConfigurationNode::RWObj_ConfigurationNode(const Handle(RWObj_Configuratio
//=======================================================================
bool RWObj_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.FileLengthUnit =
theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
InternalParameters.SystemCS = (RWMesh_CoordinateSystem)
@@ -84,7 +91,7 @@ TCollection_AsciiString RWObj_ConfigurationNode::Save() const
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Common parameters:\n";

View File

@@ -56,14 +56,6 @@ bool RWPly_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRes
InternalParameters.FileCS =
(RWMesh_CoordinateSystem)(theResource->IntegerVal("file.cs", (int)InternalParameters.SystemCS, aScope) % 2);
InternalParameters.WritePntSet =
theResource->BooleanVal("write.pnt.set", InternalParameters.WritePntSet, aScope);
InternalParameters.WriteDistance =
theResource->RealVal("write.distance", InternalParameters.WriteDistance, aScope);
InternalParameters.WriteDensity =
theResource->RealVal("write.density", InternalParameters.WriteDensity, aScope);
InternalParameters.WriteTolerance =
theResource->RealVal("write.tolerance", InternalParameters.WriteTolerance, aScope);
InternalParameters.WriteNormals =
theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
InternalParameters.WriteColors =
@@ -118,30 +110,6 @@ TCollection_AsciiString RWPly_ConfigurationNode::Save() const
aResult += "!Write parameters:\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Flag for write point cloud instead without triangulation indices\n";
aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
aResult += aScope + "write.pnt.set :\t " + InternalParameters.WritePntSet + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Distance from shape into the range [0, Value]\n";
aResult += "!Default value: 0. Available values: [0, Value]\n";
aResult += aScope + "write.distance :\t " + InternalParameters.WriteDistance + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Density of points to generate randomly on surface\n";
aResult += "!Default value: 2.e+100. Available values: [0, inf]\n";
aResult += aScope + "write.density :\t " + InternalParameters.WriteDensity + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Internal tolerance\n";
aResult += "!Default value: 1.e-7. Available values: [0, inf]\n";
aResult += aScope + "write.tolerance :\t " + InternalParameters.WriteTolerance + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Flag for write normals\n";
aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";

View File

@@ -94,10 +94,6 @@ public:
RWMesh_CoordinateSystem SystemCS = RWMesh_CoordinateSystem_Zup; //!< System origin coordinate system to perform conversion into during read
RWMesh_CoordinateSystem FileCS = RWMesh_CoordinateSystem_Yup; //!< File origin coordinate system to perform conversion during read
// Writing
bool WritePntSet = false; //!< Flag for write point cloud instead without triangulation indices
double WriteDistance = 0.0; //!< Distance from shape into the range [0, Value]
double WriteDensity = Precision::Infinite(); //!< Density of points to generate randomly on surface
double WriteTolerance = Precision::Confusion(); //!< Internal tolerance
bool WriteNormals = true; //!< Flag for write normals
bool WriteColors = true; //!< Flag for write colors
bool WriteTexCoords = false; //!< Flag for write UV / texture coordinates

View File

@@ -14,7 +14,6 @@
#include <RWPly_Provider.hxx>
#include <BRep_Builder.hxx>
#include <BRepLib_PointCloudShape.hxx>
#include <DE_Wrapper.hxx>
#include <Message.hxx>
#include <RWPly_ConfigurationNode.hxx>
@@ -80,122 +79,34 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
return Standard_True;
}
if (aNode->InternalParameters.WritePntSet)
TColStd_IndexedDataMapOfStringString aFileInfo;
if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
{
class PointCloudPlyWriter : public BRepLib_PointCloudShape, public RWPly_PlyWriterContext
{
public:
PointCloudPlyWriter(Standard_Real theTol)
: BRepLib_PointCloudShape(TopoDS_Shape(), theTol)
{}
void AddFaceColor(const TopoDS_Shape& theFace, const Graphic3d_Vec4ub& theColor)
{
myFaceColor.Bind(theFace, theColor);
}
protected:
virtual void addPoint(const gp_Pnt& thePoint,
const gp_Vec& theNorm,
const gp_Pnt2d& theUV,
const TopoDS_Shape& theFace)
{
Graphic3d_Vec4ub aColor;
myFaceColor.Find(theFace, aColor);
RWPly_PlyWriterContext::WriteVertex(thePoint,
Graphic3d_Vec3((float)theNorm.X(), (float)theNorm.Y(), (float)theNorm.Z()),
Graphic3d_Vec2((float)theUV.X(), (float)theUV.Y()),
aColor);
}
private:
NCollection_DataMap<TopoDS_Shape, Graphic3d_Vec4ub> myFaceColor;
};
PointCloudPlyWriter aPlyCtx(aNode->InternalParameters.WriteTolerance);
aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals);
aPlyCtx.SetColors(aNode->InternalParameters.WriteColors);
aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords);
TopoDS_Compound aComp;
BRep_Builder().MakeCompound(aComp);
for (XCAFPrs_DocumentExplorer aDocExplorer(theDocument, aRootLabels, XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes);
aDocExplorer.More(); aDocExplorer.Next())
{
const XCAFPrs_DocumentNode& aDocNode = aDocExplorer.Current();
for (RWMesh_FaceIterator aFaceIter(aDocNode.RefLabel, aDocNode.Location, true, aDocNode.Style); aFaceIter.More(); aFaceIter.Next())
{
BRep_Builder().Add(aComp, aFaceIter.Face());
Graphic3d_Vec4ub aColorVec(255);
if (aFaceIter.HasFaceColor())
{
Graphic3d_Vec4 aColorF = aFaceIter.FaceColor();
aColorVec.SetValues((unsigned char)int(aColorF.r() * 255.0f),
(unsigned char)int(aColorF.g() * 255.0f),
(unsigned char)int(aColorF.b() * 255.0f),
(unsigned char)int(aColorF.a() * 255.0f));
}
aPlyCtx.AddFaceColor(aFaceIter.Face(), aColorVec);
}
}
aPlyCtx.SetShape(aComp);
Standard_Integer aNbPoints = aNode->InternalParameters.WriteDensity > 0
? aPlyCtx.NbPointsByDensity(aNode->InternalParameters.WriteDensity)
: aPlyCtx.NbPointsByTriangulation();
if (aNbPoints <= 0)
{
Message::SendFail() << "Error in the RWPly_Provider during writing the file " <<
thePath << "\t: Incorrect number of points";
return false;
}
if (!aPlyCtx.Open(thePath)
|| !aPlyCtx.WriteHeader(aNbPoints, 0, TColStd_IndexedDataMapOfStringString()))
{
Message::SendFail() << "Error in the RWPly_Provider during writing the file " << thePath;
return false;
}
Standard_Boolean isDone = aNode->InternalParameters.WriteDensity > 0
? aPlyCtx.GeneratePointsByDensity(aNode->InternalParameters.WriteDensity)
: aPlyCtx.GeneratePointsByTriangulation();
if (!isDone)
{
Message::SendFail() << "Error in the RWPly_Provider during writing the file "
<< thePath << "\t: Error during generating point process";
return false;
}
aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
}
else
if (!aNode->InternalParameters.WriteComment.IsEmpty())
{
TColStd_IndexedDataMapOfStringString aFileInfo;
if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
{
aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
}
if (!aNode->InternalParameters.WriteComment.IsEmpty())
{
aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
}
RWMesh_CoordinateSystemConverter aConverter;
aConverter.SetInputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
aConverter.SetOutputLengthUnit(aNode->InternalParameters.FileLengthUnit);
aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
RWPly_CafWriter aPlyCtx(thePath);
aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals);
aPlyCtx.SetColors(aNode->InternalParameters.WriteColors);
aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords);
aPlyCtx.SetPartId(aNode->InternalParameters.WritePartId);
aPlyCtx.SetFaceId(aNode->InternalParameters.WriteFaceId);
if (!aPlyCtx.Perform(theDocument, aFileInfo, theProgress))
{
Message::SendFail() << "Error in the RWPly_Provider during writing the file "
<< thePath << "\t: Cannot perform the document";
return false;
}
aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
}
RWMesh_CoordinateSystemConverter aConverter;
aConverter.SetInputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
aConverter.SetOutputLengthUnit(aNode->InternalParameters.FileLengthUnit);
aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
RWPly_CafWriter aPlyCtx(thePath);
aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals);
aPlyCtx.SetColors(aNode->InternalParameters.WriteColors);
aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords);
aPlyCtx.SetPartId(aNode->InternalParameters.WritePartId);
aPlyCtx.SetFaceId(aNode->InternalParameters.WriteFaceId);
if (!aPlyCtx.Perform(theDocument, aFileInfo, theProgress))
{
Message::SendFail() << "Error in the RWPly_Provider during writing the file "
<< thePath << "\t: Cannot perform the document";
return false;
}
return true;
}

View File

@@ -99,11 +99,42 @@ namespace
return aPoly;
}
protected:
void Clear()
{
myNodes.Clear();
myTriangles.Clear();
}
private:
NCollection_Vector<gp_XYZ> myNodes;
NCollection_Vector<Poly_Triangle> myTriangles;
};
class MultiDomainReader : public Reader
{
public:
//! Add new solid
//! Add triangulation to triangulation list for multi-domain case
virtual void AddSolid() Standard_OVERRIDE
{
if (Handle(Poly_Triangulation) aCurrentTri = GetTriangulation())
{
myTriangulationList.Append(aCurrentTri);
}
Clear();
}
//! Returns triangulation list for multi-domain case
NCollection_Sequence<Handle(Poly_Triangulation)>& ChangeTriangulationList()
{
return myTriangulationList;
}
private:
NCollection_Sequence<Handle(Poly_Triangulation)> myTriangulationList;
};
}
//=============================================================================
@@ -122,6 +153,22 @@ Handle(Poly_Triangulation) RWStl::ReadFile (const Standard_CString theFile,
return aReader.GetTriangulation();
}
//=============================================================================
//function : ReadFile
//purpose :
//=============================================================================
void RWStl::ReadFile(const Standard_CString theFile,
const Standard_Real theMergeAngle,
NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList,
const Message_ProgressRange& theProgress)
{
MultiDomainReader aReader;
aReader.SetMergeAngle (theMergeAngle);
aReader.Read (theFile, theProgress);
theTriangList.Clear();
theTriangList.Append (aReader.ChangeTriangulationList());
}
//=============================================================================
//function : ReadFile
//purpose :

View File

@@ -20,6 +20,7 @@
#include <Poly_Triangulation.hxx>
#include <Standard_Macro.hxx>
#include <Message_ProgressScope.hxx>
#include <NCollection_Sequence.hxx>
//! This class provides methods to read and write triangulation from / to the STL files.
class RWStl
@@ -61,7 +62,17 @@ public:
Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
const Standard_Real theMergeAngle,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Read specified STL file and fills triangulation list for multi-domain case.
//! @param[in] theFile file path to read
//! @param[in] theMergeAngle maximum angle in radians between triangles to merge equal nodes; M_PI/2 means ignore angle
//! @param[out] theTriangList triangulation list for multi-domain case
//! @param[in] theProgress progress indicator
Standard_EXPORT static void ReadFile(const Standard_CString theFile,
const Standard_Real theMergeAngle,
NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Read triangulation from a binary STL file
//! In case of error, returns Null handle.
Standard_EXPORT static Handle(Poly_Triangulation) ReadBinary (const OSD_Path& thePath,

View File

@@ -19,7 +19,14 @@
IMPLEMENT_STANDARD_RTTIEXT(RWStl_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
}
//=======================================================================
// function : STEPCAFControl_ConfigurationNode
@@ -48,7 +55,7 @@ RWStl_ConfigurationNode::RWStl_ConfigurationNode(const Handle(RWStl_Configuratio
//=======================================================================
bool RWStl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.ReadMergeAngle =
theResource->RealVal("read.merge.angle", InternalParameters.ReadMergeAngle, aScope);
@@ -68,7 +75,7 @@ TCollection_AsciiString RWStl_ConfigurationNode::Save() const
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Read parameters:\n";

View File

@@ -180,6 +180,7 @@ Standard_Boolean RWStl_Reader::Read (const char* theFile,
}
}
*aStream >> std::ws; // skip any white spaces
AddSolid();
}
return ! aStream->fail();
}
@@ -300,6 +301,11 @@ Standard_Boolean RWStl_Reader::ReadAscii (Standard_IStream& theStream,
// skip header "solid ..."
aLine = theBuffer.ReadLine (theStream, aLineLen);
// skip empty lines
while (aLine && !*aLine)
{
aLine = theBuffer.ReadLine (theStream, aLineLen);
}
if (aLine == NULL)
{
Message::SendFail ("Error: premature end of file");

View File

@@ -39,7 +39,8 @@ public:
Standard_EXPORT RWStl_Reader();
//! Reads data from STL file (either binary or Ascii).
//! This function supports reading multi-domain STL files formed by concatenation of several "plain" files.
//! This function supports reading multi-domain STL files formed by concatenation
//! of several "plain" files.
//! The mesh nodes are not merged between domains.
//! Unicode paths can be given in UTF-8 encoding.
//! Format is recognized automatically by analysis of the file header.
@@ -84,6 +85,9 @@ public:
//! Should create new triangle built on specified nodes in the target model.
virtual void AddTriangle (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3) = 0;
//! Callback function to be implemented in descendant.
//! Should create a new triangulation for a solid in multi-domain case.
virtual void AddSolid() {}
public:
//! Return merge tolerance; M_PI/2 by default - all nodes are merged regardless angle between triangles.

View File

@@ -19,7 +19,14 @@
IMPLEMENT_STANDARD_RTTIEXT(STEPCAFControl_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
}
//=======================================================================
// function : STEPCAFControl_ConfigurationNode
@@ -48,7 +55,7 @@ STEPCAFControl_ConfigurationNode::STEPCAFControl_ConfigurationNode(const Handle(
//=======================================================================
bool STEPCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.ReadBSplineContinuity = (ReadMode_BSplineContinuity)
theResource->IntegerVal("read.iges.bspline.continuity", InternalParameters.ReadBSplineContinuity, aScope);
@@ -157,7 +164,7 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Common parameters:\n";

View File

@@ -17,8 +17,6 @@
#include <IFSelect_SelectModelEntities.hxx>
#include <IFSelect_SelectModelRoots.hxx>
#include <IFSelect_SelectSignature.hxx>
#include <IFSelect_Signature.hxx>
#include <Interface_Protocol.hxx>
#include <StepAP214.hxx>
#include <StepAP214_Protocol.hxx>
#include <StepData_StepModel.hxx>

View File

@@ -13,7 +13,6 @@
#include <IFSelect_EditForm.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_TypedValue.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>

View File

@@ -21,7 +21,6 @@
#include <Standard_Type.hxx>
#include <IFSelect_Editor.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
class TCollection_AsciiString;
class IFSelect_EditForm;

View File

@@ -13,7 +13,6 @@
#include <IFSelect_EditForm.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_TypedValue.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>

Some files were not shown because too many files have changed in this diff Show More