mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0031336: Modeling data - extend BRepPrimAPI_MakeBox with planar shape creation
-Create a new package BRepPreviewAPI, inherited from BRepPrimAPI to create both, valid and degenerative shapes -Create a new class BRepPreviewAPI_MakeBox for working with a box Preview can be vertex, edge, rectangle or box -BRepPrim_GWedge: in the case of non-valid data, the exception does not happen in the constructor, but at the moment of access to the shape -BRepPrimAPI_MakeBox: myWedge is now not private, but protected, because used in BRepPreviewAPI_MakeBox which inherits from BRepPrimAPI_MakeBox -Add tests for checking of a creation a preview in tests/geometry/preview (vertex, edge, rectangle, box) -Update a command "box": add new parameters
This commit is contained in:
parent
7e1c1e4869
commit
10ac040338
@ -108,6 +108,7 @@ n BRepMesh
|
||||
n BRepMeshData
|
||||
n BRepOffset
|
||||
n BRepOffsetAPI
|
||||
n BRepPreviewAPI
|
||||
n BRepPrim
|
||||
n BRepPrimAPI
|
||||
n BRepProj
|
||||
|
124
src/BRepPreviewAPI/BRepPreviewAPI_MakeBox.cxx
Normal file
124
src/BRepPreviewAPI/BRepPreviewAPI_MakeBox.cxx
Normal file
@ -0,0 +1,124 @@
|
||||
// Created on: 2020-01-31
|
||||
// Created by: Svetlana SHUTINA
|
||||
// Copyright (c) 2020 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 <BRepPreviewAPI_MakeBox.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
|
||||
#include <TopoDS_Compound.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Build
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepPreviewAPI_MakeBox::Build()
|
||||
{
|
||||
gp_Pnt anLocation = myWedge.Axes().Location();
|
||||
|
||||
gp_Pnt aFirstPoint (anLocation.X(), anLocation.Y(), anLocation.Z());
|
||||
gp_Pnt aSecondPoint (anLocation.X() + myWedge.GetXMax(), anLocation.Y() + myWedge.GetYMax(), anLocation.Z() + myWedge.GetZMax());
|
||||
|
||||
Standard_Boolean aThinOnX = Abs (aFirstPoint.X() - aSecondPoint.X()) < Precision::Confusion();
|
||||
Standard_Boolean aThinOnY = Abs (aFirstPoint.Y() - aSecondPoint.Y()) < Precision::Confusion();
|
||||
Standard_Boolean aThinOnZ = Abs (aFirstPoint.Z() - aSecondPoint.Z()) < Precision::Confusion();
|
||||
|
||||
Standard_Integer aPreviewType = (int)aThinOnX + (int)aThinOnY + (int)aThinOnZ;
|
||||
|
||||
if (aPreviewType == 3) // thin box in all directions is a point
|
||||
{
|
||||
makeVertex (aFirstPoint);
|
||||
}
|
||||
else if (aPreviewType == 2) // thin box in two directions is a point
|
||||
{
|
||||
makeEdge (aFirstPoint, aSecondPoint);
|
||||
}
|
||||
// thin box in only one direction is a rectangular face
|
||||
else if (aPreviewType == 1)
|
||||
{
|
||||
gp_Pnt aPnt1, aPnt2, aPnt3, aPnt4;
|
||||
if (aThinOnX)
|
||||
{
|
||||
aPnt1 = gp_Pnt (aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z());
|
||||
aPnt2 = gp_Pnt (aFirstPoint.X(), aSecondPoint.Y(), aFirstPoint.Z());
|
||||
aPnt3 = gp_Pnt (aFirstPoint.X(), aSecondPoint.Y(), aSecondPoint.Z());
|
||||
aPnt4 = gp_Pnt (aFirstPoint.X(), aFirstPoint.Y(), aSecondPoint.Z());
|
||||
}
|
||||
else if (aThinOnY)
|
||||
{
|
||||
aPnt1 = gp_Pnt (aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z());
|
||||
aPnt2 = gp_Pnt (aSecondPoint.X(), aFirstPoint.Y(), aFirstPoint.Z());
|
||||
aPnt3 = gp_Pnt (aSecondPoint.X(), aFirstPoint.Y(), aSecondPoint.Z());
|
||||
aPnt4 = gp_Pnt (aFirstPoint.X(), aFirstPoint.Y(), aSecondPoint.Z());
|
||||
}
|
||||
else if (aThinOnZ)
|
||||
{
|
||||
aPnt1 = gp_Pnt (aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z());
|
||||
aPnt2 = gp_Pnt (aSecondPoint.X(), aFirstPoint.Y(), aFirstPoint.Z());
|
||||
aPnt3 = gp_Pnt (aSecondPoint.X(), aSecondPoint.Y(), aFirstPoint.Z());
|
||||
aPnt4 = gp_Pnt (aFirstPoint.X(), aSecondPoint.Y(), aFirstPoint.Z());
|
||||
}
|
||||
|
||||
makeRectangle (aPnt1, aPnt2, aPnt3, aPnt4);
|
||||
}
|
||||
|
||||
if (!myShape.IsNull())
|
||||
{
|
||||
Done();
|
||||
return;
|
||||
}
|
||||
|
||||
// box is a valid shape
|
||||
Solid();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : makeVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepPreviewAPI_MakeBox::makeVertex (const gp_Pnt& thePoint)
|
||||
{
|
||||
myShape = BRepBuilderAPI_MakeVertex (thePoint);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : makeEdge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepPreviewAPI_MakeBox::makeEdge (const gp_Pnt& thePoint1, const gp_Pnt& thePoint2)
|
||||
{
|
||||
myShape = BRepBuilderAPI_MakeEdge (thePoint1, thePoint2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : makeRectangle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepPreviewAPI_MakeBox::makeRectangle (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2,
|
||||
const gp_Pnt& thePnt3, const gp_Pnt& thePnt4)
|
||||
{
|
||||
TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge (thePnt1, thePnt2);
|
||||
TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge (thePnt2, thePnt3);
|
||||
TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge (thePnt3, thePnt4);
|
||||
TopoDS_Edge anEdge4 = BRepBuilderAPI_MakeEdge (thePnt4, thePnt1);
|
||||
|
||||
BRepBuilderAPI_MakeWire aWire (anEdge1, anEdge2, anEdge3, anEdge4);
|
||||
BRepBuilderAPI_MakeFace aFace (aWire);
|
||||
|
||||
myShape = aFace.Shape();
|
||||
}
|
57
src/BRepPreviewAPI/BRepPreviewAPI_MakeBox.hxx
Normal file
57
src/BRepPreviewAPI/BRepPreviewAPI_MakeBox.hxx
Normal file
@ -0,0 +1,57 @@
|
||||
// Created on: 2020-01-31
|
||||
// Created by: Svetlana SHUTINA
|
||||
// Copyright (c) 2020 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 _BRepPreviewAPI_MakeBox_HeaderFile
|
||||
#define _BRepPreviewAPI_MakeBox_HeaderFile
|
||||
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
|
||||
//! Builds a valid box, if points fulfill the conditions of a valid box.
|
||||
//! And allows to build a preview, otherwise.
|
||||
//! There are 4 cases:
|
||||
//! 1 - preview can be a vertex if thin box in all directions is a point;
|
||||
//! 2 - preview can be an edge if thin box in two directions is a point;
|
||||
//! 3 - preview can be a rectangular face if thin box in only one direction is a point;
|
||||
//! 4 - preview can be a valid box if point values fulfill the conditions of a valid box.
|
||||
|
||||
class BRepPreviewAPI_MakeBox : public BRepPrimAPI_MakeBox
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
BRepPreviewAPI_MakeBox() {}
|
||||
|
||||
//! Creates a preview depending on point values.
|
||||
Standard_EXPORT virtual void Build() Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
//! Create a vertex if thin box in all directions is a point.
|
||||
void makeVertex (const gp_Pnt& thePoint);
|
||||
|
||||
//! Create an edge if thin box in two directions is a point.
|
||||
void makeEdge (const gp_Pnt& thePoint1, const gp_Pnt& thePoint2);
|
||||
|
||||
//! Create a rectangular face if the box is thin in one direction only.
|
||||
//! @param thePnt1 the first point for a rectangular face
|
||||
//! @param thePnt2 the second point for a rectangular face
|
||||
//! @param thePnt3 the third point for a rectangular face
|
||||
//! @param thePnt4 the fourth point for a rectangular face
|
||||
void makeRectangle (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2,
|
||||
const gp_Pnt& thePnt3, const gp_Pnt& thePnt4);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
2
src/BRepPreviewAPI/FILES
Normal file
2
src/BRepPreviewAPI/FILES
Normal file
@ -0,0 +1,2 @@
|
||||
BRepPreviewAPI_MakeBox.hxx
|
||||
BRepPreviewAPI_MakeBox.cxx
|
@ -134,6 +134,27 @@ static void BRepPrim_Wedge_Init(Standard_Boolean& S,
|
||||
F[i] = Standard_False;
|
||||
}
|
||||
|
||||
BRepPrim_GWedge::BRepPrim_GWedge() :
|
||||
XMin (0),
|
||||
XMax (0),
|
||||
YMin (0),
|
||||
YMax (0),
|
||||
ZMin (0),
|
||||
ZMax (0),
|
||||
Z2Min (0),
|
||||
Z2Max (0),
|
||||
X2Min (0),
|
||||
X2Max (0)
|
||||
{
|
||||
for (Standard_Integer i = 0; i < NBFACES; i++)
|
||||
{
|
||||
myInfinite[i]=Standard_False;
|
||||
}
|
||||
|
||||
BRepPrim_Wedge_Init (ShellBuilt,VerticesBuilt,EdgesBuilt,
|
||||
WiresBuilt,FacesBuilt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepPrim_GWedge
|
||||
//purpose : build a box
|
||||
@ -158,10 +179,7 @@ BRepPrim_GWedge::BRepPrim_GWedge (const BRepPrim_Builder& B,
|
||||
X2Max(dx)
|
||||
{
|
||||
for (Standard_Integer i = 0; i < NBFACES; i++) { myInfinite[i]=Standard_False; }
|
||||
if ( ( dx <= Precision::Confusion() ) ||
|
||||
( dy <= Precision::Confusion() ) ||
|
||||
( dz <= Precision::Confusion() ) )
|
||||
throw Standard_DomainError();
|
||||
|
||||
BRepPrim_Wedge_Init(ShellBuilt,VerticesBuilt,EdgesBuilt,
|
||||
WiresBuilt,FacesBuilt);
|
||||
}
|
||||
@ -191,11 +209,7 @@ BRepPrim_GWedge::BRepPrim_GWedge (const BRepPrim_Builder& B,
|
||||
X2Max(ltx)
|
||||
{
|
||||
for (Standard_Integer i = 0; i < NBFACES; i++) { myInfinite[i]=Standard_False; }
|
||||
if ( ( dx <= Precision::Confusion() ) ||
|
||||
( dy <= Precision::Confusion() ) ||
|
||||
( dz <= Precision::Confusion() ) ||
|
||||
( ltx < 0 ) )
|
||||
throw Standard_DomainError();
|
||||
|
||||
BRepPrim_Wedge_Init(ShellBuilt,VerticesBuilt,EdgesBuilt,
|
||||
WiresBuilt,FacesBuilt);
|
||||
}
|
||||
@ -231,12 +245,7 @@ BRepPrim_GWedge::BRepPrim_GWedge (const BRepPrim_Builder& B,
|
||||
X2Max(x2max)
|
||||
{
|
||||
for (Standard_Integer i = 0; i < NBFACES; i++) { myInfinite[i]=Standard_False; }
|
||||
if ( ( XMax-XMin <= Precision::Confusion() ) ||
|
||||
( YMax-YMin <= Precision::Confusion() ) ||
|
||||
( ZMax-ZMin <= Precision::Confusion() ) ||
|
||||
( Z2Max-Z2Min < 0 ) ||
|
||||
( X2Max-X2Min < 0 ) )
|
||||
throw Standard_DomainError();
|
||||
|
||||
BRepPrim_Wedge_Init(ShellBuilt,VerticesBuilt,EdgesBuilt,
|
||||
WiresBuilt,FacesBuilt);
|
||||
}
|
||||
@ -296,6 +305,9 @@ Standard_Boolean BRepPrim_GWedge::IsInfinite (const BRepPrim_Direction d1) const
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Shell& BRepPrim_GWedge::Shell() {
|
||||
if (IsDegeneratedShape())
|
||||
throw Standard_DomainError();
|
||||
|
||||
if (!ShellBuilt) {
|
||||
myBuilder.MakeShell(myShell);
|
||||
|
||||
@ -1020,3 +1032,19 @@ const TopoDS_Vertex& BRepPrim_GWedge::Vertex
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDegeneratedShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepPrim_GWedge::IsDegeneratedShape()
|
||||
{
|
||||
if ( ( XMax-XMin <= Precision::Confusion() ) ||
|
||||
( YMax-YMin <= Precision::Confusion() ) ||
|
||||
( ZMax-ZMin <= Precision::Confusion() ) ||
|
||||
( Z2Max-Z2Min < 0 ) ||
|
||||
( X2Max-X2Min < 0 ) )
|
||||
return Standard_True;
|
||||
else
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,8 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Default constructor
|
||||
Standard_EXPORT BRepPrim_GWedge();
|
||||
|
||||
//! Creates a GWedge algorithm. <Axes> is the axis
|
||||
//! system for the primitive.
|
||||
@ -191,7 +193,9 @@ public:
|
||||
//! <d1><d2><d3> direction.
|
||||
Standard_EXPORT gp_Pnt Point (const BRepPrim_Direction d1, const BRepPrim_Direction d2, const BRepPrim_Direction d3);
|
||||
|
||||
|
||||
//! Checkes a shape on degeneracy
|
||||
//! @return TRUE if a shape is degenerated
|
||||
Standard_EXPORT Standard_Boolean IsDegeneratedShape();
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -34,6 +34,8 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Default constructor
|
||||
BRepPrim_Wedge() {}
|
||||
|
||||
//! Creates a Wedge algorithm. <Axes> is the axis
|
||||
//! system for the primitive.
|
||||
|
@ -102,6 +102,56 @@ BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(const gp_Ax2& Axes,
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepPrimAPI_MakeBox::Init (const Standard_Real theDX, const Standard_Real theDY, const Standard_Real theDZ)
|
||||
{
|
||||
myWedge = BRepPrim_Wedge (gp_Ax2 (pmin (gp_Pnt (0, 0, 0), theDX, theDY, theDZ), gp_Dir (0, 0, 1), gp_Dir (1, 0, 0)),
|
||||
Abs (theDX), Abs (theDY), Abs (theDZ));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepPrimAPI_MakeBox::Init (const gp_Pnt& thePnt,
|
||||
const Standard_Real theDX,
|
||||
const Standard_Real theDY,
|
||||
const Standard_Real theDZ)
|
||||
{
|
||||
myWedge = BRepPrim_Wedge (gp_Ax2 (pmin (thePnt, theDX, theDY, theDZ), gp_Dir (0, 0, 1), gp_Dir (1, 0, 0)),
|
||||
Abs (theDX), Abs (theDY), Abs (theDZ));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepPrimAPI_MakeBox::Init (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2)
|
||||
{
|
||||
myWedge = BRepPrim_Wedge (gp_Ax2 (pmin (thePnt1,thePnt2), gp_Dir (0, 0, 1), gp_Dir (1, 0, 0)),
|
||||
Abs (thePnt2.X() - thePnt1.X()),
|
||||
Abs (thePnt2.Y() - thePnt1.Y()),
|
||||
Abs (thePnt2.Z() - thePnt1.Z()));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepPrimAPI_MakeBox::Init (const gp_Ax2& theAxes,
|
||||
const Standard_Real theDX,
|
||||
const Standard_Real theDY,
|
||||
const Standard_Real theDZ)
|
||||
{
|
||||
myWedge = BRepPrim_Wedge (theAxes, theDX, theDY, theDZ);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Wedge
|
||||
|
@ -40,23 +40,6 @@ class TopoDS_Face;
|
||||
//! - defining the construction of a box,
|
||||
//! - implementing the construction algorithm, and
|
||||
//! - consulting the result.
|
||||
class BRepPrimAPI_MakeBox : public BRepBuilderAPI_MakeShape
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Make a box with a corner at 0,0,0 and the other dx,dy,dz
|
||||
Standard_EXPORT BRepPrimAPI_MakeBox(const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);
|
||||
|
||||
//! Make a box with a corner at P and size dx, dy, dz.
|
||||
Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Pnt& P, const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);
|
||||
|
||||
//! Make a box with corners P1,P2.
|
||||
Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Pnt& P1, const gp_Pnt& P2);
|
||||
|
||||
//! Ax2 is the left corner and the axis.
|
||||
//! Constructs a box such that its sides are parallel to the axes of
|
||||
//! - the global coordinate system, or
|
||||
//! - the local coordinate system Axis. and
|
||||
@ -70,8 +53,47 @@ public:
|
||||
//! component projected onto the global coordinate
|
||||
//! system less than or equal to Precision::Confusion().
|
||||
//! In these cases, the box would be flat.
|
||||
|
||||
class BRepPrimAPI_MakeBox : public BRepBuilderAPI_MakeShape
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Default constructor
|
||||
BRepPrimAPI_MakeBox() {}
|
||||
|
||||
//! Make a box with a corner at 0,0,0 and the other dx,dy,dz
|
||||
Standard_EXPORT BRepPrimAPI_MakeBox(const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);
|
||||
|
||||
//! Make a box with a corner at P and size dx, dy, dz.
|
||||
Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Pnt& P, const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);
|
||||
|
||||
//! Make a box with corners P1,P2.
|
||||
Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Pnt& P1, const gp_Pnt& P2);
|
||||
|
||||
//! Make a box with Ax2 (the left corner and the axis) and size dx, dy, dz.
|
||||
Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Ax2& Axes, const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);
|
||||
|
||||
//! Init a box with a corner at 0,0,0 and the other theDX, theDY, theDZ
|
||||
Standard_EXPORT void Init (const Standard_Real theDX, const Standard_Real theDY, const Standard_Real theDZ);
|
||||
|
||||
//! Init a box with a corner at thePnt and size theDX, theDY, theDZ.
|
||||
Standard_EXPORT void Init (const gp_Pnt& thePnt,
|
||||
const Standard_Real theDX,
|
||||
const Standard_Real theDY,
|
||||
const Standard_Real theDZ);
|
||||
|
||||
//! Init a box with corners thePnt1, thePnt2.
|
||||
Standard_EXPORT void Init (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2);
|
||||
|
||||
//! Init a box with Ax2 (the left corner and the theAxes) and size theDX, theDY, theDZ.
|
||||
Standard_EXPORT void Init (const gp_Ax2& theAxes,
|
||||
const Standard_Real theDX,
|
||||
const Standard_Real theDY,
|
||||
const Standard_Real theDZ);
|
||||
|
||||
//! Returns the internal algorithm.
|
||||
Standard_EXPORT BRepPrim_Wedge& Wedge();
|
||||
|
||||
@ -110,6 +132,7 @@ Standard_EXPORT operator TopoDS_Solid();
|
||||
protected:
|
||||
|
||||
|
||||
BRepPrim_Wedge myWedge;
|
||||
|
||||
|
||||
|
||||
@ -117,7 +140,6 @@ private:
|
||||
|
||||
|
||||
|
||||
BRepPrim_Wedge myWedge;
|
||||
|
||||
|
||||
};
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <TopoDS_Solid.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepBuilderAPI.hxx>
|
||||
#include <BRepPreviewAPI_MakeBox.hxx>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <BRepPrimAPI_MakeWedge.hxx>
|
||||
#include <BRepPrimAPI_MakeCylinder.hxx>
|
||||
@ -39,28 +40,153 @@
|
||||
|
||||
static Standard_Integer box(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 5) return 1;
|
||||
Standard_Real dx = Draw::Atof(a[n-3]);
|
||||
Standard_Real dy = Draw::Atof(a[n-2]);
|
||||
Standard_Real dz = Draw::Atof(a[n-1]);
|
||||
gp_Pnt anOrigin;
|
||||
gp_XYZ aParams;
|
||||
gp_Dir aDir;
|
||||
gp_Dir aXDir;
|
||||
Standard_Boolean isMinMax = Standard_False;
|
||||
Standard_Boolean isPreview = Standard_False;
|
||||
Standard_Boolean isAxis = Standard_False;
|
||||
|
||||
TopoDS_Solid S;
|
||||
|
||||
if (n > 5) {
|
||||
if (n < 8) return 1;
|
||||
Standard_Real x = Draw::Atof(a[2]);
|
||||
Standard_Real y = Draw::Atof(a[3]);
|
||||
Standard_Real z = Draw::Atof(a[4]);
|
||||
S = BRepPrimAPI_MakeBox(gp_Pnt(x,y,z),dx,dy,dz);
|
||||
for (Standard_Integer anArgIter = 2; anArgIter < n; ++anArgIter)
|
||||
{
|
||||
TCollection_AsciiString anArgCase (a[anArgIter]);
|
||||
anArgCase.LowerCase();
|
||||
if (anArgCase == "-min" && anArgIter + 3 <= n)
|
||||
{
|
||||
anOrigin.SetX (Draw::Atof(a[anArgIter + 1]));
|
||||
anOrigin.SetY (Draw::Atof(a[anArgIter + 2]));
|
||||
anOrigin.SetZ (Draw::Atof(a[anArgIter + 3]));
|
||||
anArgIter += 3;
|
||||
}
|
||||
else {
|
||||
S = BRepPrimAPI_MakeBox(dx,dy,dz);
|
||||
else if (anArgCase == "-max" && anArgIter + 3 <= n)
|
||||
{
|
||||
aParams.SetX (Draw::Atof(a[anArgIter + 1]));
|
||||
aParams.SetY (Draw::Atof(a[anArgIter + 2]));
|
||||
aParams.SetZ (Draw::Atof(a[anArgIter + 3]));
|
||||
isMinMax = Standard_True;
|
||||
anArgIter += 3;
|
||||
}
|
||||
else if (anArgCase == "-size" && anArgIter + 3 <= n)
|
||||
{
|
||||
aParams.SetX (Draw::Atof(a[anArgIter + 1]));
|
||||
aParams.SetY (Draw::Atof(a[anArgIter + 2]));
|
||||
aParams.SetZ (Draw::Atof(a[anArgIter + 3]));
|
||||
isMinMax = Standard_False;
|
||||
anArgIter += 3;
|
||||
}
|
||||
else if (anArgCase == "-dir" && anArgIter + 3 <= n)
|
||||
{
|
||||
Standard_Real aX = Draw::Atof(a[anArgIter + 1]);
|
||||
Standard_Real anY = Draw::Atof(a[anArgIter + 2]);
|
||||
Standard_Real aZ = Draw::Atof(a[anArgIter + 3]);
|
||||
aDir.SetCoord (aX, anY, aZ);
|
||||
isAxis = Standard_True;
|
||||
anArgIter += 3;
|
||||
}
|
||||
else if (anArgCase == "-xdir" && anArgIter + 3 <= n)
|
||||
{
|
||||
Standard_Real aX = Draw::Atof(a[anArgIter + 1]);
|
||||
Standard_Real anY = Draw::Atof(a[anArgIter + 2]);
|
||||
Standard_Real aZ = Draw::Atof(a[anArgIter + 3]);
|
||||
aXDir.SetCoord (aX, anY, aZ);
|
||||
isAxis = Standard_True;
|
||||
anArgIter += 3;
|
||||
}
|
||||
else if (anArgCase == "-preview")
|
||||
{
|
||||
isPreview = Standard_True;
|
||||
}
|
||||
else if (anArgIter + 5 < n || anArgIter + 2 < n)
|
||||
{
|
||||
Standard_Real aValue = 0.0;
|
||||
Standard_Integer aCountReal = 0;
|
||||
Standard_Integer anIter = anArgIter;
|
||||
while (anIter < n && Draw::ParseReal(a[anIter], aValue))
|
||||
{
|
||||
anIter++;
|
||||
aCountReal++;
|
||||
}
|
||||
|
||||
if (aCountReal == 6)
|
||||
{
|
||||
anOrigin.SetX (Draw::Atof(a[anArgIter]));
|
||||
anOrigin.SetY (Draw::Atof(a[anArgIter + 1]));
|
||||
anOrigin.SetZ (Draw::Atof(a[anArgIter + 2]));
|
||||
|
||||
aParams.SetX (Draw::Atof(a[anArgIter + 3]));
|
||||
aParams.SetY (Draw::Atof(a[anArgIter + 4]));
|
||||
aParams.SetZ (Draw::Atof(a[anArgIter + 5]));
|
||||
anArgIter += 5;
|
||||
}
|
||||
|
||||
else if (aCountReal == 3)
|
||||
{
|
||||
aParams.SetX (Draw::Atof(a[anArgIter]));
|
||||
aParams.SetY (Draw::Atof(a[anArgIter + 1]));
|
||||
aParams.SetZ (Draw::Atof(a[anArgIter + 2]));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Syntax error\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isPreview)
|
||||
{
|
||||
TopoDS_Shape S;
|
||||
BRepPreviewAPI_MakeBox aPreview;
|
||||
|
||||
if (isMinMax == Standard_True)
|
||||
{
|
||||
aPreview.Init (anOrigin, aParams);
|
||||
}
|
||||
else if (isMinMax == Standard_False && isAxis == Standard_False)
|
||||
{
|
||||
aPreview.Init (anOrigin, aParams.X(), aParams.Y(), aParams.Z());
|
||||
}
|
||||
else if (isAxis)
|
||||
{
|
||||
gp_Ax2 anAxis (anOrigin, aDir, aXDir);
|
||||
aPreview.Init (anAxis, aParams.X(), aParams.Y(), aParams.Z());
|
||||
}
|
||||
else
|
||||
{
|
||||
aPreview.Init (aParams.X(), aParams.Y(), aParams.Z());
|
||||
}
|
||||
|
||||
S = aPreview;
|
||||
DBRep::Set(a[1],S);
|
||||
}
|
||||
else
|
||||
{
|
||||
TopoDS_Solid S;
|
||||
if (isMinMax == Standard_True)
|
||||
{
|
||||
S = BRepPrimAPI_MakeBox(anOrigin, aParams);
|
||||
}
|
||||
else if (isMinMax == Standard_False && isAxis == Standard_False)
|
||||
{
|
||||
S = BRepPrimAPI_MakeBox(anOrigin, aParams.X(), aParams.Y(), aParams.Z());
|
||||
}
|
||||
else if (isAxis)
|
||||
{
|
||||
gp_Ax2 anAxis (anOrigin, aDir, aXDir);
|
||||
S = BRepPrimAPI_MakeBox(anAxis, aParams.X(), aParams.Y(), aParams.Z());
|
||||
}
|
||||
else
|
||||
{
|
||||
S = BRepPrimAPI_MakeBox(aParams.X(), aParams.Y(), aParams.Z());
|
||||
}
|
||||
DBRep::Set(a[1],S);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
// wedge
|
||||
//=======================================================================
|
||||
@ -274,7 +400,20 @@ void BRepTest::PrimitiveCommands(Draw_Interpretor& theCommands)
|
||||
|
||||
const char* g = "Primitive building commands";
|
||||
|
||||
theCommands.Add("box","box name [x1 y1 z1] dx dy dz",__FILE__,box,g);
|
||||
theCommands.Add ("box",
|
||||
"box name [dx dy dz] [x y z dx dy dz]"
|
||||
"\n\t\t: [-min x y z] [-size dx dy dz] [-max x y z]"
|
||||
"\n\t\t: [-dir x y z -xdir x y z] [-preview]"
|
||||
"\n\t\t: Construct axes-aligned box and put result into 'name' variable"
|
||||
"\n\t\t: -min box lower corner, origin; (0,0,0) by default"
|
||||
"\n\t\t: -size box dimensions (alternative to -max)"
|
||||
"\n\t\t: -max box upper corner (alternative to -size)"
|
||||
"\n\t\t: -dir main direction of coordinate system (DZ by default)"
|
||||
"\n\t\t: -xdir x direction of coordinate system (DX by default)"
|
||||
"\n\t\t: -preview non-solid shape will be created (vertex, edge, rectangle or box);"
|
||||
"\n\t\t: otherwise, return NULL shape in case of zero box dimension.",
|
||||
__FILE__,box,g);
|
||||
|
||||
theCommands.Add("wedge","wedge name [Ox Oy Oz Zx Zy Zz Xx Xy Xz] dx dy dz ltx / xmin zmin xmax zmax",__FILE__,wedge,g);
|
||||
|
||||
theCommands.Add("pcylinder","pcylinder name [plane(ax2)] R H [angle]",__FILE__,cylinder,g);
|
||||
|
@ -1,4 +1,5 @@
|
||||
BRepPrim
|
||||
BRepSweep
|
||||
Sweep
|
||||
BRepPreviewAPI
|
||||
BRepPrimAPI
|
||||
|
@ -10,6 +10,7 @@
|
||||
010 law
|
||||
011 line
|
||||
012 parabola
|
||||
013 project
|
||||
014 revsurf
|
||||
015 2dpolygon
|
||||
013 preview
|
||||
014 project
|
||||
015 revsurf
|
||||
016 2dpolygon
|
39
tests/geometry/preview/box
Normal file
39
tests/geometry/preview/box
Normal file
@ -0,0 +1,39 @@
|
||||
puts "=================================="
|
||||
puts "0031336: Modeling data - extend BRepPrimAPI_MakeBox with planar shape creation"
|
||||
puts "Check a creation preview if it is a valid box and creation a box"
|
||||
puts "=================================="
|
||||
|
||||
pload TOPTEST
|
||||
|
||||
smallview
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
set anImage3 $imagedir/${casename}_3.png
|
||||
set anImage4 $imagedir/${casename}_4.png
|
||||
set anImage5 $imagedir/${casename}_5.png
|
||||
|
||||
box b1 0.0 0.0 0.0 10.0 10.0 10.0 -preview
|
||||
donly b1
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage1
|
||||
|
||||
box b2 -min 0.0 0.0 0.0 -max 10.0 20.0 30.0 -preview
|
||||
donly b2
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage2
|
||||
|
||||
box b3 0.0 0.0 0.0 10.0 10.0 10.0
|
||||
donly b3
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage3
|
||||
|
||||
box b4 -min 0.0 0.0 0.0 -max 10.0 20.0 30.0
|
||||
donly b4
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage4
|
||||
|
||||
box b5 20.0 20.0 20.0
|
||||
donly b5
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage5
|
21
tests/geometry/preview/edge
Normal file
21
tests/geometry/preview/edge
Normal file
@ -0,0 +1,21 @@
|
||||
puts "=================================="
|
||||
puts "0031336: Modeling data - extend BRepPrimAPI_MakeBox with planar shape creation"
|
||||
puts "Check a creation preview if it is an edge"
|
||||
puts "=================================="
|
||||
|
||||
pload TOPTEST
|
||||
|
||||
smallview +X+Y
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
|
||||
box edge1 0.0 0.0 0.0 10.0 0.0 0.0 -preview
|
||||
donly edge1
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage1
|
||||
|
||||
box edge2 -min 30.0 0.0 0.0 -max 40.0 0.0 0.0 -preview
|
||||
donly edge2
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage2
|
21
tests/geometry/preview/rectangle
Normal file
21
tests/geometry/preview/rectangle
Normal file
@ -0,0 +1,21 @@
|
||||
puts "=================================="
|
||||
puts "0031336: Modeling data - extend BRepPrimAPI_MakeBox with planar shape creation"
|
||||
puts "Check a creation preview if it is a rectangle"
|
||||
puts "=================================="
|
||||
|
||||
pload TOPTEST
|
||||
|
||||
smallview +X+Y
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
|
||||
box rect1 0.0 0.0 0.0 10.0 10.0 0.0 -preview
|
||||
donly rect1
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage1
|
||||
|
||||
box rect2 -min 30.0 40.0 0.0 -max 50.0 60.0 0.0 -preview
|
||||
donly rect2
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage2
|
21
tests/geometry/preview/vertex
Normal file
21
tests/geometry/preview/vertex
Normal file
@ -0,0 +1,21 @@
|
||||
puts "=================================="
|
||||
puts "0031336: Modeling data - extend BRepPrimAPI_MakeBox with planar shape creation"
|
||||
puts "Check a creation preview if it is a vertex"
|
||||
puts "=================================="
|
||||
|
||||
pload TOPTEST
|
||||
|
||||
smallview +X+Y
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
|
||||
box vertex1 0.0 0.0 0.0 0.0 0.0 0.0 -preview
|
||||
donly vertex1
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage1
|
||||
|
||||
box vertex2 -min 30.0 0.0 0.0 -max 30.0 0.0 0.0 -preview
|
||||
donly vertex2
|
||||
fit
|
||||
checkview -screenshot -2d -path $anImage2
|
Loading…
x
Reference in New Issue
Block a user