NRI : bad merge.

This commit is contained in:
nri 2003-07-09 15:11:49 +00:00
parent 08ddac36db
commit 7fcf0fe5b4
53 changed files with 0 additions and 11825 deletions

View File

@ -1,147 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_AISShape.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
/*!
\class GEOM_AISShape GEOM_AISShape.hxx
\brief ....
*/
#include "GEOM_AISShape.ixx"
#include "SALOME_InteractiveObject.hxx"
#include "utilities.h"
// Open CASCADE Includes
#include <AIS_Drawer.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <StdSelect_DisplayMode.hxx>
#include <StdPrs_WFShape.hxx>
#include <StdPrs_ShadedShape.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
const Standard_CString aName): SALOME_AISShape(shape)
{
myIO = NULL;
myName = new char [strlen(aName)+1];
strcpy( myName, aName);
myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
}
void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
myIO = io;
}
Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO(){
return myIO;
}
Standard_Boolean GEOM_AISShape::hasIO(){
return !( myIO == NULL ) ;
}
void GEOM_AISShape::setName(const Standard_CString aName)
{
myName = new char [strlen(aName)+1];
strcpy( myName, aName);
if ( hasIO() )
myIO->setName(aName);
}
Standard_CString GEOM_AISShape::getName(){
return myName;
}
void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPrs,
const Standard_Integer aMode)
{
if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode;
switch (d) {
case StdSelect_DM_Wireframe:
{
StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
break;
}
case StdSelect_DM_Shading:
{
myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(Graphic3d_NOM_BRASS);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Graphic3d_NOM_JADE);
Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
FMat.SetTransparency(myTransparency); BMat.SetTransparency(myTransparency);
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
//Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
// P->SetPrimitivesAspect(a4bis);
// G->SetGroupPrimitivesAspect(a4bis);
//a4bis->SetInteriorColor(myShadingColor);
myDrawer->ShadingAspect()->SetColor(myShadingColor);
StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
break;
}
}
// aPrs->ReCompute(); // for hidden line recomputation if necessary...
}
void GEOM_AISShape::SetTransparency(const Standard_Real aValue)
{
if(aValue<0.0 || aValue>1.0) return;
if(aValue<=0.05)
{
UnsetTransparency();
return;
}
Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
FMat.SetTransparency(aValue); BMat.SetTransparency(aValue);
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
myTransparency = aValue;
}
void GEOM_AISShape::SetShadingColor(const Quantity_Color &aCol)
{
myShadingColor = aCol;
}

View File

@ -1,136 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_AISShape.hxx
// Module : GEOM
#ifndef _GEOM_AISShape_HeaderFile
#define _GEOM_AISShape_HeaderFile
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_GEOM_AISShape_HeaderFile
#include "Handle_GEOM_AISShape.hxx"
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
#include "Handle_SALOME_InteractiveObject.hxx"
#endif
#ifndef _Standard_CString_HeaderFile
#include <Standard_CString.hxx>
#endif
#ifndef _SALOME_AISShape_HeaderFile
#include "SALOME_AISShape.hxx"
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Handle_PrsMgr_PresentationManager3d_HeaderFile
#include <Handle_PrsMgr_PresentationManager3d.hxx>
#endif
#ifndef _Handle_Prs3d_Presentation_HeaderFile
#include <Handle_Prs3d_Presentation.hxx>
#endif
class PrsMgr_PresentationManager3d;
class Prs3d_Presentation;
class SALOME_InteractiveObject;
class TopoDS_Shape;
class GEOM_AISShape : public SALOME_AISShape {
public:
inline void* operator new(size_t,void* anAddress)
{
return anAddress;
}
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
}
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// inline void operator delete(void *anAddress, size_t size)
// {
// if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
// }
// Methods PUBLIC
//
Standard_EXPORT GEOM_AISShape(const TopoDS_Shape& shape, const Standard_CString aName);
Standard_EXPORT Standard_Boolean hasIO() ;
Standard_EXPORT void setIO(const Handle(SALOME_InteractiveObject)& name) ;
Standard_EXPORT void setName(const Standard_CString aName) ;
Standard_EXPORT Standard_CString getName() ;
Standard_EXPORT Handle_SALOME_InteractiveObject getIO() ;
Standard_EXPORT ~GEOM_AISShape();
Standard_EXPORT void SetTransparency(const Standard_Real aValue);
Standard_EXPORT void SetShadingColor(const Quantity_Color &aCol);
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer aMode = 0) ;
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& GEOM_AISShape_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
Handle_SALOME_InteractiveObject myIO;
Standard_CString myName;
Quantity_Color myShadingColor;
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -1,91 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_AISShape.ixx
// Module : GEOM
#include "GEOM_AISShape.jxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
GEOM_AISShape::~GEOM_AISShape() {}
Standard_EXPORT Handle_Standard_Type& GEOM_AISShape_Type_()
{
static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_AISShape);
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_AISShape);
static Handle_Standard_Type aType2 = STANDARD_TYPE(AIS_Shape);
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(AIS_Shape);
static Handle_Standard_Type aType3 = STANDARD_TYPE(AIS_InteractiveObject);
if ( aType3.IsNull()) aType3 = STANDARD_TYPE(AIS_InteractiveObject);
static Handle_Standard_Type aType4 = STANDARD_TYPE(SelectMgr_SelectableObject);
if ( aType4.IsNull()) aType4 = STANDARD_TYPE(SelectMgr_SelectableObject);
static Handle_Standard_Type aType5 = STANDARD_TYPE(PrsMgr_PresentableObject);
if ( aType5.IsNull()) aType5 = STANDARD_TYPE(PrsMgr_PresentableObject);
static Handle_Standard_Type aType6 = STANDARD_TYPE(MMgt_TShared);
if ( aType6.IsNull()) aType6 = STANDARD_TYPE(MMgt_TShared);
static Handle_Standard_Type aType7 = STANDARD_TYPE(Standard_Transient);
if ( aType7.IsNull()) aType7 = STANDARD_TYPE(Standard_Transient);
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,aType5,aType6,aType7,NULL};
static Handle_Standard_Type _aType = new Standard_Type("GEOM_AISShape",
sizeof(GEOM_AISShape),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
// DownCast method
// allow safe downcasting
//
const Handle(GEOM_AISShape) Handle(GEOM_AISShape)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOM_AISShape) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(GEOM_AISShape))) {
_anOtherObject = Handle(GEOM_AISShape)((Handle(GEOM_AISShape)&)AnObject);
}
}
return _anOtherObject ;
}
const Handle(Standard_Type)& GEOM_AISShape::DynamicType() const
{
return STANDARD_TYPE(GEOM_AISShape) ;
}
Standard_Boolean GEOM_AISShape::IsKind(const Handle(Standard_Type)& AType) const
{
return (STANDARD_TYPE(GEOM_AISShape) == AType || SALOME_AISShape::IsKind(AType));
}
Handle_GEOM_AISShape::~Handle_GEOM_AISShape() {}

View File

@ -1,41 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_AISShape.jxx
// Module : GEOM
#ifndef _GEOM_InteractiveObject_HeaderFile
#include "GEOM_InteractiveObject.hxx"
#endif
#ifndef _TopoDS_Shape_HeaderFile
#include <TopoDS_Shape.hxx>
#endif
#ifndef _GEOM_AISShape_HeaderFile
#include "GEOM_AISShape.hxx"
#endif
#ifndef _PrsMgr_PresentationManager3d_HeaderFile
#include <PrsMgr_PresentationManager3d.hxx>
#endif
#ifndef _Prs3d_Presentation_HeaderFile
#include <Prs3d_Presentation.hxx>
#endif

View File

@ -1,464 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_Actor.cxx
// Author : Christophe ATTANASIO
// Module : GEOM
// $Header$
using namespace std;
/*!
\class GEOM_Actor GEOM_Actor.h
\brief This class allows to display an OpenCASCADE CAD model in a VTK viewer.
*/
#include "GEOM_Actor.h"
// OpenCASCADE Includes
#include "GEOM_OCCReader.h"
#include <BRep_Tool.hxx>
//-------------------------------------------------------------
// Main methods
//-------------------------------------------------------------
GEOM_Actor* GEOM_Actor::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("GEOM_Actor");
if(ret)
{
return (GEOM_Actor*)ret;
}
// If the factory was unable to create the object, then create it here.
return new GEOM_Actor;
}
GEOM_Actor::GEOM_Actor()
{
this->Device = vtkActor::New();
this->WireframeMapper = NULL;
this->ShadingMapper = NULL;
this->ShadingProperty = NULL;
this->WireframeProperty = NULL;
this->deflection = 0;
myDisplayMode = 0;
this->myIO = NULL;
this->myName = "";
this->HighlightProperty = NULL;
this->ishighlighted = false;
this->subshape = false;
}
GEOM_Actor::~GEOM_Actor()
{
if (WireframeMapper != NULL)
WireframeMapper->Delete();
if (ShadingMapper != NULL)
ShadingMapper->Delete();
if (ShadingProperty != NULL)
ShadingProperty->Delete();
if (WireframeProperty != NULL)
WireframeProperty->Delete();
if (HighlightProperty != NULL)
HighlightProperty->Delete();
}
void GEOM_Actor::ShallowCopy(vtkProp *prop)
{
GEOM_Actor *f = GEOM_Actor::SafeDownCast(prop);
if ( f != NULL )
{
this->setInputShape(f->getTopo(),f->getDeflection(),f->getDisplayMode());
this->setName( f->getName() );
if ( f->hasIO() )
this->setIO( f->getIO() );
this->ShadingMapper = NULL;
this->WireframeMapper = NULL;
} else {
this->myIO = NULL;
this->myName = "";
this->ShadingMapper = NULL;
this->WireframeMapper = NULL;
}
// Now do superclass
this->SALOME_Actor::ShallowCopy(prop);
}
//-------------------------------------------------------------
// Set parameters
//-------------------------------------------------------------
void GEOM_Actor::setDisplayMode(int thenewmode) {
myDisplayMode = thenewmode;
if ( thenewmode >=1 ) {
if ((myShape.ShapeType() == TopAbs_WIRE) ||
(myShape.ShapeType() == TopAbs_EDGE) ||
(myShape.ShapeType() == TopAbs_VERTEX)) {
if ( !subshape )
CreateWireframeMapper();
else
return;
} else
CreateShadingMapper();
} else
CreateWireframeMapper();
}
void GEOM_Actor::setDeflection(double adef) {
deflection = adef;
}
void GEOM_Actor::setInputShape(const TopoDS_Shape& aShape,double adef,int imode) {
myShape = aShape;
deflection = adef;
setDisplayMode(imode);
}
//-------------------------------------------------------------
// Get parameters
//-------------------------------------------------------------
const TopoDS_Shape& GEOM_Actor::getTopo() {
return myShape;
}
double GEOM_Actor::getDeflection() {
return deflection;
}
void GEOM_Actor::SetWireframeProperty(vtkProperty* Prop) {
this->WireframeProperty = Prop;
}
void GEOM_Actor::SetShadingProperty(vtkProperty* Prop) {
this->ShadingProperty = Prop;
}
//-------------------------------------------------------------
// Mapper creating function
//-------------------------------------------------------------
void GEOM_Actor::CreateMapper(int theMode) {
if(myShape.ShapeType() == TopAbs_VERTEX) {
gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(myShape));
this->SetPosition(aPnt.X(),aPnt.Y(),aPnt.Z());
}
GEOM_OCCReader* aread = GEOM_OCCReader::New();
aread->setTopo(myShape);
aread->setDisplayMode(theMode);
aread->GetOutput()->ReleaseDataFlagOn();
vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
if (theMode == 0) {
aMapper->SetInput(aread->GetOutput());
} else {
vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
normals->SetInput(aread->GetOutput());
aMapper->SetInput(normals->GetOutput());
}
aread->Delete();
this->SetMapper(theMode == 0? WireframeMapper = aMapper : ShadingMapper = aMapper);
}
void GEOM_Actor::CreateShadingMapper() {
CreateMapper(1);
}
void GEOM_Actor::CreateWireframeMapper() {
CreateMapper(0);
}
//-------------------------------------------------------------
// Render function
//-------------------------------------------------------------
void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper)
{
/* render the property */
if (!this->Property) {
// force creation of a property
this->GetProperty();
this->Property->SetInterpolation(1);
this->Property->SetRepresentationToSurface();
this->Property->SetAmbient(0.3);
this->Property->SetAmbientColor(0.88,0.86,0.2);
this->Property->SetDiffuseColor(0.99,0.7,0.21);
this->Property->SetSpecularColor(0.99,0.98,0.83);
}
if(!ishighlighted) {
if(myDisplayMode >= 1) {
// SHADING
this->Property = ShadingProperty;
}
else {
this->Property = WireframeProperty;
}
if ( ispreselected )
this->Property = PreviewProperty;
}
this->Property->Render(this, ren);
if (this->BackfaceProperty) {
this->BackfaceProperty->BackfaceRender(this, ren);
this->Device->SetBackfaceProperty(this->BackfaceProperty);
}
this->Device->SetProperty(this->Property);
// Store information on time it takes to render.
// We might want to estimate time from the number of polygons in mapper.
if(myDisplayMode >= 1) {
if((myShape.ShapeType() == TopAbs_WIRE) ||
(myShape.ShapeType() == TopAbs_EDGE) ||
(myShape.ShapeType() == TopAbs_VERTEX)) {
if ( !subshape ) {
if(WireframeMapper==NULL) CreateWireframeMapper();
} else
return;
}
else {
if(ShadingMapper==NULL) CreateShadingMapper();
}
}
else {
if(WireframeMapper==NULL) CreateWireframeMapper();
}
if(myShape.ShapeType() == TopAbs_VERTEX) {
if(ren){
//The parameter determine size of vertex actor relate to diagonal of RendererWindow
static float delta = 0.01;
float X1 = -1, Y1 = -1, Z1 = 0;
ren->ViewToWorld(X1,Y1,Z1);
float X2 = +1, Y2 = +1, Z2 = 0;
ren->ViewToWorld(X2,Y2,Z2);
Z2 = sqrt((X2-X1)*(X2-X1) + (Y2-Y1)*(Y2-Y1) + (Z2-Z1)*(Z2-Z1));
this->SetScale(Z2*delta);
}
vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
this->GetMatrix(ren->GetActiveCamera(), aMatrix);
this->Device->SetUserMatrix(aMatrix);
this->Device->Render(ren,this->Mapper);
aMatrix->Delete();
} else
this->Device->Render(ren, this->Mapper);
this->EstimatedRenderTime = WireframeMapper->GetTimeToDraw();
}
// SubShape
void GEOM_Actor::SubShapeOn()
{
subshape = true;
}
void GEOM_Actor::SubShapeOff()
{
subshape = false;
}
//-------------------------------------------------------------
// Opacity methods
//-------------------------------------------------------------
void GEOM_Actor::SetOpacity(float opa)
{
//HighlightProperty->SetOpacity(opa);
SALOME_Actor::SetOpacity(opa);
ShadingProperty->SetOpacity(opa);
}
float GEOM_Actor::GetOpacity() {
return ShadingProperty->GetOpacity();
}
//-------------------------------------------------------------
// Color methods
//-------------------------------------------------------------
void GEOM_Actor::SetColor(float r,float g,float b) {
ShadingProperty->SetColor(r,g,b);
}
void GEOM_Actor::GetColor(float& r,float& g,float& b) {
float color[3];
ShadingProperty->GetColor(color);
r = color[0];
g = color[1];
b = color[2];
}
//-------------------------------------------------------------
// Highlight methods
//-------------------------------------------------------------
void GEOM_Actor::highlight(Standard_Boolean highlight) {
if(highlight && !ishighlighted) {
ishighlighted=true;
// build highlight property is necessary
if(HighlightProperty==NULL) {
HighlightProperty = vtkProperty::New();
HighlightProperty->SetAmbient(0.5);
HighlightProperty->SetDiffuse(0.3);
HighlightProperty->SetSpecular(0.2);
HighlightProperty->SetRepresentationToSurface();
HighlightProperty->SetAmbientColor(1, 1, 1);
HighlightProperty->SetDiffuseColor(1, 1, 1);
HighlightProperty->SetSpecularColor(0.5, 0.5, 0.5);
}
this->Property = HighlightProperty;
}
else if (!highlight) {
if(ishighlighted) {
ishighlighted=false;
if(myDisplayMode==1) {
//unhilight in shading
this->Property = ShadingProperty;
}
else {
//unhilight in wireframe
this->Property = WireframeProperty;
}
}
}
}
bool GEOM_Actor::hasHighlight()
{
return true;
}
void GEOM_Actor::SetHighlightProperty(vtkProperty* Prop) {
this->HighlightProperty = Prop;
}
void GEOM_Actor::ReleaseGraphicsResources(vtkWindow *renWin)
{
vtkActor::ReleaseGraphicsResources(renWin);
// broadcast the message down to the individual LOD mappers
if(WireframeMapper) this->WireframeMapper->ReleaseGraphicsResources(renWin);
if(ShadingMapper) this->ShadingMapper->ReleaseGraphicsResources(renWin);
}
// Copy the follower's composite 4x4 matrix into the matrix provided.
void GEOM_Actor::GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result)
{
double *pos, *vup;
double Rx[3], Ry[3], Rz[3], p1[3];
vtkMatrix4x4 *matrix = vtkMatrix4x4::New();
int i;
double distance;
this->GetOrientation();
this->Transform->Push();
this->Transform->PostMultiply();
this->Transform->Identity();
// apply user defined matrix last if there is one
if (this->UserMatrix)
{
this->Transform->Concatenate(this->UserMatrix);
}
this->Transform->Translate(-this->Origin[0],
-this->Origin[1],
-this->Origin[2]);
// scale
this->Transform->Scale(this->Scale[0],
this->Scale[1],
this->Scale[2]);
// rotate
this->Transform->RotateY(this->Orientation[1]);
this->Transform->RotateX(this->Orientation[0]);
this->Transform->RotateZ(this->Orientation[2]);
if (theCam)
{
// do the rotation
// first rotate y
pos = theCam->GetPosition();
vup = theCam->GetViewUp();
if (theCam->GetParallelProjection())
{
theCam->GetDirectionOfProjection(Rz);
}
else
{
distance = sqrt(
(pos[0] - this->Position[0])*(pos[0] - this->Position[0]) +
(pos[1] - this->Position[1])*(pos[1] - this->Position[1]) +
(pos[2] - this->Position[2])*(pos[2] - this->Position[2]));
for (i = 0; i < 3; i++)
{
Rz[i] = (pos[i] - this->Position[i])/distance;
}
}
vtkMath::Cross(vup,Rz,Rx);
vtkMath::Normalize(Rx);
vtkMath::Cross(Rz,Rx,Ry);
matrix->Element[0][0] = Rx[0];
matrix->Element[1][0] = Rx[1];
matrix->Element[2][0] = Rx[2];
matrix->Element[0][1] = Ry[0];
matrix->Element[1][1] = Ry[1];
matrix->Element[2][1] = Ry[2];
matrix->Element[0][2] = Rz[0];
matrix->Element[1][2] = Rz[1];
matrix->Element[2][2] = Rz[2];
this->Transform->Concatenate(matrix);
}
// translate to projection reference point PRP
// this is the camera's position blasted through
// the current matrix
p1[0] = this->Origin[0] + this->Position[0];
p1[1] = this->Origin[1] + this->Position[1];
p1[2] = this->Origin[2] + this->Position[2];
this->Transform->Translate(p1[0],p1[1],p1[2]);
this->Transform->GetMatrix(result);
matrix->Delete();
this->Transform->Pop();
}

View File

@ -1,125 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_Actor.h
// Author : Christophe ATTANASIO
// Module : GEOM
// $Header$
#ifndef GEOM_ACTOR_H
#define GEOM_ACTOR_H
#include "SALOME_Actor.h"
//OpenCASCADE
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
class TopoDS_Shape;
#ifdef _WIN_32
#define VTKOCC_EXPORT __declspec (dllexport)
#else
#define VTKOCC_EXPORT
#endif
class VTKOCC_EXPORT GEOM_Actor : public SALOME_Actor {
public:
vtkTypeMacro(GEOM_Actor,SALOME_Actor);
static GEOM_Actor* New();
// Description:
// This causes the actor to be rendered. It, in turn, will render the actor's
// property and then mapper.
virtual void Render(vtkRenderer *, vtkMapper *);
// Description:
// Release any graphics resources that are being consumed by this actor.
// The parameter window could be used to determine which graphic
// resources to release.
void ReleaseGraphicsResources(vtkWindow *);
const TopoDS_Shape& getTopo();
void setInputShape(const TopoDS_Shape& ashape,double adef1,int imode);
double getDeflection();
void setDeflection(double adefl);
// SubShape
void SubShapeOn();
void SubShapeOff();
// Display Mode
void setDisplayMode(int);
// Highlight
void highlight(Standard_Boolean highlight);
bool hasHighlight();
void ShallowCopy(vtkProp *prop);
// Properties
void SetHighlightProperty(vtkProperty* Prop);
void SetWireframeProperty(vtkProperty* Prop);
void SetShadingProperty(vtkProperty* Prop);
// Opacity
void SetOpacity(float opa);
float GetOpacity();
// Color
void SetColor(float r,float g,float b);
void GetColor(float& r,float& g,float& b);
protected:
GEOM_Actor();
~GEOM_Actor();
GEOM_Actor(const GEOM_Actor&) {};
void operator=(const GEOM_Actor&) {};
void CreateWireframeMapper();
void CreateShadingMapper();
void CreateMapper(int theMode);
void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
private:
bool subshape;
TopoDS_Shape myShape;
double deflection;
vtkMapper* ShadingMapper;
vtkMapper* WireframeMapper;
vtkProperty* ShadingProperty;
vtkProperty* WireframeProperty;
vtkProperty* HighlightProperty;
};
#endif //GEOM_ACTOR_H

View File

@ -1,421 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_AssemblyBuilder.cxx
// Author : Christophe ATTANASIO
// Module : GEOM
// $Header$
using namespace std;
/*!
\class GEOM_AssemblyBuilder GEOM_AssemblyBuilder.h
\brief ....
*/
#include "GEOM_AssemblyBuilder.h"
#include "GEOM_Actor.h"
#include "utilities.h"
// Open CASCADE Includes
#include <TopExp_Explorer.hxx>
#include <Bnd_Box.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <Poly_Triangulation.hxx>
#include <BRepBndLib.hxx>
#include <BRep_Tool.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopExp.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Iterator.hxx>
// SALOME
#define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) )
#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) )
void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp,
vtkProperty* FaceProp,
vtkProperty* EdgeFProp,
vtkProperty* EdgeSProp,
vtkProperty* EdgeIProp,
vtkProperty* VertexProp,
vtkProperty* IsoPVProp,
vtkProperty* EdgePVProp,
vtkProperty* VertexPVProp)
{
// Shading like default OCC material
FaceProp->SetRepresentationToSurface();
FaceProp->SetInterpolation(1);
FaceProp->SetAmbient(1.0);
FaceProp->SetDiffuse(1.0);
FaceProp->SetSpecular(0.4);
FaceProp->SetAmbientColor(0.329412, 0.223529, 0.027451);
FaceProp->SetDiffuseColor(0.780392, 0.568627, 0.113725);
FaceProp->SetSpecularColor(0.992157, 0.941176, 0.807843);
// Wireframe for iso
IsoProp->SetRepresentationToWireframe();
IsoProp->SetAmbientColor(0.5, 0.5, 0.5);
IsoProp->SetDiffuseColor(0.5, 0.5, 0.5);
IsoProp->SetSpecularColor(0.5, 0.5, 0.5);
// Wireframe for iso
IsoPVProp->SetRepresentationToWireframe();
IsoPVProp->SetAmbientColor(0, 1, 1);
IsoPVProp->SetDiffuseColor(0, 1, 1);
IsoPVProp->SetSpecularColor(0, 1, 1);
// Wireframe for shared edge
EdgeSProp->SetRepresentationToWireframe();
EdgeSProp->SetAmbientColor(1, 1, 0);
EdgeSProp->SetDiffuseColor(1, 1, 0);
EdgeSProp->SetSpecularColor(1, 1, 0);
// Wireframe for free edge
EdgeFProp->SetRepresentationToWireframe();
EdgeFProp->SetAmbientColor(0, 1, 0);
EdgeFProp->SetDiffuseColor(0, 1, 0);
EdgeFProp->SetSpecularColor(0, 1, 0);
// Wireframe for isolated edge
EdgeIProp->SetRepresentationToWireframe();
EdgeIProp->SetAmbientColor(1, 0, 0);
EdgeIProp->SetDiffuseColor(1, 0, 0);
EdgeIProp->SetSpecularColor(1, 0, 0);
// Wireframe for Preview edge
EdgePVProp->SetRepresentationToWireframe();
EdgePVProp->SetAmbientColor(0, 1, 1);
EdgePVProp->SetDiffuseColor(0, 1, 1);
EdgePVProp->SetSpecularColor(0, 1, 1);
// Wireframe for vertex
VertexProp->SetRepresentationToWireframe();
VertexProp->SetAmbientColor(1, 1, 0);
VertexProp->SetDiffuseColor(1, 1, 0);
VertexProp->SetSpecularColor(1, 1, 0);
// Wireframe for vertex
VertexPVProp->SetRepresentationToWireframe();
VertexPVProp->SetAmbientColor(0, 1, 1);
VertexPVProp->SetDiffuseColor(0, 1, 1);
VertexPVProp->SetSpecularColor(0, 1, 1);
}
void GEOM_AssemblyBuilder::MeshShape(const TopoDS_Shape myShape,
Standard_Real deflection,
Standard_Boolean forced)
{
// Mesh the shape if necessary
Standard_Boolean alreadymesh = Standard_True;
TopExp_Explorer ex;
TopLoc_Location aLoc;
for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
}
if(!alreadymesh || forced) {
if(deflection<=0) {
// Compute default deflection
Bnd_Box B;
BRepBndLib::Add(myShape, B);
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
deflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin) * 0.001 *4;
}
BRepMesh_IncrementalMesh MESH(myShape,deflection);
}
}
vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShape,
Standard_Real deflection,
Standard_Integer mode,
Standard_Boolean forced) {
vtkActorCollection* AISActors = vtkActorCollection::New();
if(myShape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator anItr(myShape);
for(; anItr.More(); anItr.Next()) {
vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(anItr.Value(), deflection, mode, forced);
theActors->InitTraversal();
vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
while(!(anActor==NULL)) {
AISActors->AddItem(anActor);
anActor = (vtkActor*)theActors->GetNextActor();
}
}
}
// Create graphics properties
vtkProperty* IsoProp = vtkProperty::New();
vtkProperty* FaceProp = vtkProperty::New();
vtkProperty* EdgeFProp = vtkProperty::New();
vtkProperty* EdgeSProp = vtkProperty::New();
vtkProperty* EdgeIProp = vtkProperty::New();
vtkProperty* VertexProp = vtkProperty::New();
vtkProperty* IsoPVProp = vtkProperty::New();
vtkProperty* EdgePVProp = vtkProperty::New();
vtkProperty* VertexPVProp = vtkProperty::New();
InitProperties(IsoProp,FaceProp,EdgeFProp,EdgeSProp,EdgeIProp,VertexProp,IsoPVProp,EdgePVProp,VertexPVProp);
MeshShape(myShape,deflection,forced);
if ( myShape.ShapeType() <= 4 && myShape.ShapeType() != TopAbs_COMPOUND) {
// FACE Actor
// look if edges are free or shared
TopTools_IndexedDataMapOfShapeListOfShape edgemap;
TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
TopExp_Explorer ex;
for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
GEOM_Actor* FaceActor = GEOM_Actor::New();
FaceActor->SetShadingProperty(FaceProp);
FaceActor->SetWireframeProperty(IsoProp);
FaceActor->SetPreviewProperty(IsoPVProp);
FaceActor->setInputShape(ex.Current(),deflection,mode);
AISActors->AddItem(FaceActor);
TopExp_Explorer ex2;
for (ex2.Init(ex.Current(), TopAbs_EDGE); ex2.More(); ex2.Next()) {
const TopoDS_Edge& aEdge = TopoDS::Edge(ex2.Current());
if (BRep_Tool::Degenerated(aEdge)) {
continue;
}
// compute the number of faces
Standard_Integer nbf = edgemap.FindFromKey(ex2.Current()).Extent();
GEOM_Actor* EdgeActor = GEOM_Actor::New();
EdgeActor->SubShapeOn();
EdgeActor->setInputShape(ex2.Current(),deflection,mode);
switch (nbf) {
case 0 : // isolated edge
{
EdgeActor->SetShadingProperty(EdgeIProp);
EdgeActor->SetWireframeProperty(EdgeIProp);
}
break;
case 1 :// edge in only one face
{
EdgeActor->SetShadingProperty(EdgeFProp);
EdgeActor->SetWireframeProperty(EdgeFProp);
}
break;
default : // edge shared by at least two faces
{
EdgeActor->SetShadingProperty(EdgeSProp);
EdgeActor->SetWireframeProperty(EdgeSProp);
}
}
EdgeActor->SetPreviewProperty(EdgePVProp);
AISActors->AddItem(EdgeActor);
}
}
} else if ( myShape.ShapeType() == TopAbs_WIRE ) { // WIRE Actor
TopExp_Explorer ex;
for (ex.Init(myShape, TopAbs_EDGE); ex.More(); ex.Next()) {
const TopoDS_Edge& aEdge = TopoDS::Edge(ex.Current());
if (BRep_Tool::Degenerated(aEdge)) {
continue;
}
GEOM_Actor* EdgeActor = GEOM_Actor::New();
EdgeActor->setInputShape(ex.Current(),deflection,mode);
EdgeActor->SetShadingProperty(EdgeIProp);
EdgeActor->SetWireframeProperty(EdgeIProp);
EdgeActor->SetPreviewProperty(EdgePVProp);
AISActors->AddItem(EdgeActor);
}
} else if ( myShape.ShapeType() == TopAbs_EDGE ) { // EDGE Actor
GEOM_Actor* EdgeActor = GEOM_Actor::New();
EdgeActor->setInputShape(myShape,deflection,mode);
EdgeActor->SetShadingProperty(EdgeIProp);
EdgeActor->SetWireframeProperty(EdgeIProp);
EdgeActor->SetPreviewProperty(EdgePVProp);
AISActors->AddItem(EdgeActor);
} else if ( myShape.ShapeType() == TopAbs_VERTEX ) { // VERTEX Actor
GEOM_Actor* VertexActor = GEOM_Actor::New();
VertexActor->setInputShape(myShape,deflection,mode);
VertexActor->SetShadingProperty(VertexProp);
VertexActor->SetWireframeProperty(VertexProp);
VertexActor->SetPreviewProperty(VertexPVProp);
AISActors->AddItem(VertexActor);
}
return AISActors;
}
//-------------------------------------------------------------
// BUILD ASSEMBLY
//-------------------------------------------------------------
vtkAssembly* GEOM_AssemblyBuilder::BuildAssembly(const TopoDS_Shape& myShape,
Standard_Real deflection,
Standard_Integer mode,
Standard_Boolean forced)
{
// Create a new vtkAssembly
vtkAssembly* myVTKShape = vtkAssembly::New();
// Create graphics properties
vtkProperty* IsoProp = vtkProperty::New();
vtkProperty* FaceProp = vtkProperty::New();
vtkProperty* EdgeFProp = vtkProperty::New();
vtkProperty* EdgeSProp = vtkProperty::New();
vtkProperty* EdgeIProp = vtkProperty::New();
vtkProperty* VertexProp = vtkProperty::New();
vtkProperty* EdgePVProp = vtkProperty::New();
vtkProperty* VertexPVProp = vtkProperty::New();
vtkProperty* IsoPVProp = vtkProperty::New();
InitProperties(IsoProp,FaceProp,EdgeFProp,EdgeSProp,EdgeIProp,VertexProp,IsoPVProp,EdgePVProp,VertexPVProp);
MeshShape(myShape,deflection,forced);
// FACE Actor
// look if edges are free or shared
TopTools_IndexedDataMapOfShapeListOfShape edgemap;
TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
TopExp_Explorer ex;
for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
//const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
GEOM_Actor* FaceActor = GEOM_Actor::New();
FaceActor->SetShadingProperty(FaceProp);
FaceActor->SetWireframeProperty(IsoProp);
vtkAssembly* myFaceAssembly = vtkAssembly::New();
FaceActor->setInputShape(ex.Current(),deflection,mode);
myFaceAssembly->AddPart(FaceActor);
TopExp_Explorer ex2;
for (ex2.Init(ex.Current(), TopAbs_EDGE); ex2.More(); ex2.Next()) {
const TopoDS_Edge& aEdge = TopoDS::Edge(ex2.Current());
if (BRep_Tool::Degenerated(aEdge)) {
continue;
}
// compute the number of faces
Standard_Integer nbf = edgemap.FindFromKey(ex2.Current()).Extent();
GEOM_Actor* EdgeActor = GEOM_Actor::New();
switch (nbf) {
case 0 : // isolated edge
{
EdgeActor->SetShadingProperty(EdgeIProp);
EdgeActor->SetWireframeProperty(EdgeIProp);
}
break;
case 1 :// edge in only one face
{
EdgeActor->SetShadingProperty(EdgeFProp);
EdgeActor->SetWireframeProperty(EdgeFProp);
}
break;
default : // edge shared by at least two faces
{
EdgeActor->SetShadingProperty(EdgeSProp);
EdgeActor->SetWireframeProperty(EdgeSProp);
}
}
EdgeActor->setInputShape(ex2.Current(),deflection,mode);
myFaceAssembly->AddPart(EdgeActor);
}
myVTKShape->AddPart(myFaceAssembly);
}
return myVTKShape;
}
//-------------------------------------------------------------
// CHANGE SPECIFIC DISPLAY MODE
//-------------------------------------------------------------
void GEOM_AssemblyBuilder::SwitchDisplayMode(vtkAssembly* aOCCAssembly)
{
}
void GEOM_AssemblyBuilder::SwitchDisplayMode(vtkActorCollection* aOCCAssembly)
{
}
//-------------------------------------------------------------
// DISPLAY/ERASE
//-------------------------------------------------------------
void GEOM_AssemblyBuilder::DisplayErase(vtkAssembly* mySALOMEAssembly)
{
}
void GEOM_AssemblyBuilder::DisplayErase(vtkActorCollection* mySALOMEActors)
{
}

View File

@ -1,93 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_AssemblyBuilder.h
// Author : Christophe ATTANASIO
// Module : GEOM
// $Header$
#include <vtkAssembly.h>
#include <vtkPropAssembly.h>
#include <vtkActorCollection.h>
// Open CASCADE Inlcudes
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
class GEOM_AssemblyBuilder {
private:
static void InitProperties(vtkProperty* IsoProp,
vtkProperty* FaceProp,
vtkProperty* EdgeFProp,
vtkProperty* EdgeSProp,
vtkProperty* EdgeIProp,
vtkProperty* VertexProp,
vtkProperty* IsoPVProp,
vtkProperty* EdgePVProp,
vtkProperty* VertePVProp);
static void MeshShape(const TopoDS_Shape myShape,
Standard_Real deflection,
Standard_Boolean forced);
public:
//------------------------------------------------------------------
// WARNING! Poor graphic performance :-( use BuildActors instead
//------------------------------------------------------------------
static vtkAssembly* BuildAssembly(const TopoDS_Shape& myShape,
Standard_Real deflection,
Standard_Integer amode,
Standard_Boolean forced);
//------------------------------------------------------------------
// Good performance
//------------------------------------------------------------------
static vtkActorCollection* BuildActors(const TopoDS_Shape& myShape,
Standard_Real deflection,
Standard_Integer amode,
Standard_Boolean forced);
//------------------------------------------------------------------
// Change mode - Not implemented !!
//------------------------------------------------------------------
static void SwitchDisplayMode(vtkAssembly* mySALOMEAssembly);
static void SwitchDisplayMode(vtkActorCollection* mySALOMEActors);
//------------------------------------------------------------------
// Erase/Display - Not implemented !!
//------------------------------------------------------------------
static void DisplayErase(vtkAssembly* mySALOMEAssembly);
static void DisplayErase(vtkActorCollection* mySALOMEActors);
};

View File

@ -1,76 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_InteractiveObject.cxx
// Author : Christophe ATTANASIO
// Module : GEOM
// $Header$
using namespace std;
/*!
\class GEOM_InteractiveObject GEOM_InteractiveObject.hxx
\brief ....
*/
#include "GEOM_InteractiveObject.ixx"
GEOM_InteractiveObject::GEOM_InteractiveObject()
: SALOME_InteractiveObject()
{
myIOR = "";
myFatherIOR = "";
}
GEOM_InteractiveObject::GEOM_InteractiveObject(const Standard_CString anIOR,
const Standard_CString aFatherIOR,
const Standard_CString aComponentDataType,
const Standard_CString anEntry)
: SALOME_InteractiveObject(anEntry,aComponentDataType)
{
myIOR = new char [strlen(anIOR)+1];
strcpy( myIOR, anIOR);
myFatherIOR = new char [strlen(aFatherIOR)+1];
strcpy( myFatherIOR, aFatherIOR);
}
Standard_CString GEOM_InteractiveObject::getIOR(){
return myIOR;
}
Standard_CString GEOM_InteractiveObject::getFatherIOR(){
return myFatherIOR;
}
Standard_Boolean GEOM_InteractiveObject::isSame(const Handle(SALOME_InteractiveObject)& anIO ){
if ( anIO->hasEntry() && this->hasEntry() ) {
if ( strcmp(myEntry, anIO->getEntry() ) == 0 )
return Standard_True;
}
if ( anIO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) {
Handle(GEOM_InteractiveObject) theIO = Handle(GEOM_InteractiveObject)::DownCast( anIO );
if ( strcmp(myIOR, theIO->getIOR() ) == 0 )
return Standard_True;
}
return Standard_False;
}

View File

@ -1,127 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_InteractiveObject.hxx
// Module : GEOM
#ifndef _GEOM_InteractiveObject_HeaderFile
#define _GEOM_InteractiveObject_HeaderFile
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_GEOM_InteractiveObject_HeaderFile
#include "Handle_GEOM_InteractiveObject.hxx"
#endif
#ifndef _Standard_CString_HeaderFile
#include <Standard_CString.hxx>
#endif
#ifndef _SALOME_InteractiveObject_HeaderFile
#include "SALOME_InteractiveObject.hxx"
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
#include "Handle_SALOME_InteractiveObject.hxx"
#endif
class SALOME_InteractiveObject;
class GEOM_InteractiveObject : public SALOME_InteractiveObject {
public:
inline void* operator new(size_t,void* anAddress)
{
return anAddress;
}
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
}
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// inline void operator delete(void *anAddress, size_t size)
// {
// if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
// }
// Methods PUBLIC
//
Standard_EXPORT GEOM_InteractiveObject();
Standard_EXPORT GEOM_InteractiveObject(const Standard_CString anIOR,
const Standard_CString aFatherIOR,
const Standard_CString aComponentDataType,
const Standard_CString anEntry = "");
Standard_EXPORT void setIOR(const Standard_CString anEntry) ;
Standard_EXPORT Standard_CString getIOR() ;
Standard_EXPORT void setFatherIOR(const Standard_CString anEntry) ;
Standard_EXPORT Standard_CString getFatherIOR() ;
Standard_EXPORT virtual Standard_Boolean isSame(const Handle(SALOME_InteractiveObject)& anIO) ;
Standard_EXPORT ~GEOM_InteractiveObject();
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& GEOM_InteractiveObject_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
Standard_CString myIOR;
Standard_CString myFatherIOR;
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -1,83 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_InteractiveObject.ixx
// Module : GEOM
#include "GEOM_InteractiveObject.jxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
GEOM_InteractiveObject::~GEOM_InteractiveObject() {}
Standard_EXPORT Handle_Standard_Type& GEOM_InteractiveObject_Type_()
{
static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_InteractiveObject);
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_InteractiveObject);
static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
static Handle_Standard_Type _aType = new Standard_Type("GEOM_InteractiveObject",
sizeof(GEOM_InteractiveObject),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
// DownCast method
// allow safe downcasting
//
const Handle(GEOM_InteractiveObject) Handle(GEOM_InteractiveObject)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOM_InteractiveObject) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) {
_anOtherObject = Handle(GEOM_InteractiveObject)((Handle(GEOM_InteractiveObject)&)AnObject);
}
}
return _anOtherObject ;
}
const Handle(Standard_Type)& GEOM_InteractiveObject::DynamicType() const
{
return STANDARD_TYPE(GEOM_InteractiveObject) ;
}
Standard_Boolean GEOM_InteractiveObject::IsKind(const Handle(Standard_Type)& AType) const
{
return (STANDARD_TYPE(GEOM_InteractiveObject) == AType || SALOME_InteractiveObject::IsKind(AType));
}
Handle_GEOM_InteractiveObject::~Handle_GEOM_InteractiveObject() {}

View File

@ -1,32 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_InteractiveObject.jxx
// Module : GEOM
#ifndef _SALOME_InteractiveObject_HeaderFile
#include "SALOME_InteractiveObject.hxx"
#endif
#ifndef _GEOM_InteractiveObject_HeaderFile
#include "GEOM_InteractiveObject.hxx"
#endif

View File

@ -1,988 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_OCCReader.h
// Author : Christophe ATTANASIO
// Module : GEOM
// $Header$
using namespace std;
#include "GEOM_OCCReader.h"
// SALOME Includes
#include "utilities.h"
// VTK Includes
#include "VTKViewer_Common.h"
#include <vtkMergePoints.h>
// OpenCASCADE Includes
#include <BRepAdaptor_Surface.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <BRepBndLib.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
#include <Precision.hxx>
#include <BRepTools.hxx>
#include <BRep_Tool.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dHatch_Intersector.hxx>
#include <Geom2dHatch_Hatcher.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <HatchGen_Domain.hxx>
#include <GeomAbs_IsoType.hxx>
#include <Precision.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Pnt2d.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <Adaptor3d_HCurve.hxx>
#define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) )
#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) )
// Constante for iso building
static Standard_Real IntersectorConfusion = 1.e-10 ; // -8 ;
static Standard_Real IntersectorTangency = 1.e-10 ; // -8 ;
static Standard_Real HatcherConfusion2d = 1.e-8 ;
static Standard_Real HatcherConfusion3d = 1.e-8 ;
static Standard_Integer lastVTKpoint = 0;
static Standard_Integer PlotCount = 0;
static Standard_Real IsoRatio = 1.001;
static Standard_Integer MaxPlotCount = 5;
//=======================================================================
// Function : New
// Purpose :
//=======================================================================
GEOM_OCCReader* GEOM_OCCReader::New()
{
vtkObject* ret = vtkObjectFactory::CreateInstance("GEOM_OCCReader");
if(ret) {
return (GEOM_OCCReader*)ret;
}
return new GEOM_OCCReader;
}
//=======================================================================
// Function : GEOM_OCCReader
// Purpose :
//=======================================================================
GEOM_OCCReader::GEOM_OCCReader()
{
//this->myShape = NULL;
this->amode = 0;
this->forced = Standard_False;
this->discretiso = 15;
this->nbisos = 1;
}
//=======================================================================
// Function : ~GEOM_OCCReader
// Purpose :
//=======================================================================
GEOM_OCCReader::~GEOM_OCCReader()
{
}
//=======================================================================
// Function : Execute
// Purpose :
//=======================================================================
void GEOM_OCCReader::Execute() {
vtkPolyData* output = this->GetOutput();
vtkPoints* Pts = NULL;
vtkCellArray* Cells = NULL;
TopLoc_Location aLoc;
// Allocation
Pts = vtkPoints::New();
Cells = vtkCellArray::New();
//Compute number of triangles and points
Standard_Integer nbpoly=0,nbpts=0;
if(amode==1) {
//for shading
if(myShape.ShapeType() == TopAbs_FACE) {
// whole FACE
const TopoDS_Face& aFace = TopoDS::Face(myShape);
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
if(aPoly.IsNull()) {
Pts->Delete();
Cells->Delete();
return;
}
nbpts = aPoly->NbNodes();
nbpoly = aPoly->NbTriangles();
Pts->SetNumberOfPoints(nbpts);
Cells->Allocate(Cells->EstimateSize(nbpoly,3));
}
else {
Cells->Delete();
Pts->Delete();
return;
}
}
// Start computation
if(amode == 0) {
ComputeWireframe(Pts,Cells);
output->SetPoints(Pts);
output->SetLines(Cells);
output->Squeeze();
}
else {
if(myShape.ShapeType() == TopAbs_FACE) {
ComputeShading(Pts,Cells);
output->SetPoints(Pts);
output->SetPolys(Cells);
output->Squeeze();
}
}
Pts->Delete();
Cells->Delete();
}
//=======================================================================
// Function : ComputeWireframe
// Purpose : Compute the shape in CAD wireframe mode
//=======================================================================
void GEOM_OCCReader::ComputeWireframe(vtkPoints* Pts,vtkCellArray* Cells){
// Check the type of the shape:
if(myShape.ShapeType() == TopAbs_FACE) {
// Face
TransferFaceWData(TopoDS::Face(myShape),Pts,Cells);
} else if(myShape.ShapeType() == TopAbs_EDGE) {
// Edge
TransferEdgeWData(TopoDS::Edge(myShape),Pts,Cells);
} else {
if(myShape.ShapeType() == TopAbs_VERTEX) {
// Vertex
TransferVertexWData(TopoDS::Vertex(myShape),Pts,Cells);
}
}
}
//=======================================================================
// Function : TransferFaceWData
// Purpose : Transfert wireframe data for FACE
//=======================================================================
void GEOM_OCCReader::TransferFaceWData(const TopoDS_Face& aFace,
vtkPoints* Pts,
vtkCellArray* Cells)
{
TopoDS_Face aCopyFace = aFace;
aCopyFace.Orientation (TopAbs_FORWARD);
createISO(aCopyFace,Precision::Infinite(),1,Pts,Cells);
}
//=======================================================================
// Function : createISO
// Purpose : Create ISO for Face Wireframe representation
//=======================================================================
void GEOM_OCCReader::createISO (const TopoDS_Face& TopologicalFace,
const Standard_Real Infinite,
const Standard_Integer NbIsos,
vtkPoints* Pts,
vtkCellArray* Cell)
{
Geom2dHatch_Hatcher aHatcher (Geom2dHatch_Intersector (IntersectorConfusion,
IntersectorTangency),
HatcherConfusion2d,
HatcherConfusion3d,
Standard_True,
Standard_False);
Standard_Real myInfinite,myUMin,myUMax,myVMin,myVMax;
//myInfinite = Precision::Infinite();
myInfinite = 1e38; // VTK uses float numbers - Precision::Infinite() is double and can not be accepted.
Standard_Integer myNbDom;
TColStd_Array1OfReal myUPrm(1, NbIsos),myVPrm(1, NbIsos);
TColStd_Array1OfInteger myUInd(1, NbIsos),myVInd(1, NbIsos);
myUInd.Init(0);
myVInd.Init(0);
//-----------------------------------------------------------------------
// If the Min Max bounds are infinite, there are bounded to Infinite
// value.
//-----------------------------------------------------------------------
BRepTools::UVBounds (TopologicalFace, myUMin, myUMax, myVMin, myVMax) ;
Standard_Boolean InfiniteUMin = Precision::IsNegativeInfinite (myUMin) ;
Standard_Boolean InfiniteUMax = Precision::IsPositiveInfinite (myUMax) ;
Standard_Boolean InfiniteVMin = Precision::IsNegativeInfinite (myVMin) ;
Standard_Boolean InfiniteVMax = Precision::IsPositiveInfinite (myVMax) ;
if (InfiniteUMin && InfiniteUMax) {
myUMin = - myInfinite ;
myUMax = myInfinite ;
} else if (InfiniteUMin) {
myUMin = myUMax - myInfinite ;
} else if (InfiniteUMax) {
myUMax = myUMin + myInfinite ;
}
if (InfiniteVMin && InfiniteVMax) {
myVMin = - myInfinite ;
myVMax = myInfinite ;
} else if (InfiniteVMin) {
myVMin = myVMax - myInfinite ;
} else if (InfiniteVMax) {
myVMax = myVMin + myInfinite ;
}
//-----------------------------------------------------------------------
// Retreiving the edges and loading them into the hatcher.
//-----------------------------------------------------------------------
TopExp_Explorer ExpEdges ;
for (ExpEdges.Init (TopologicalFace, TopAbs_EDGE) ; ExpEdges.More() ; ExpEdges.Next()) {
const TopoDS_Edge& TopologicalEdge = TopoDS::Edge (ExpEdges.Current()) ;
Standard_Real U1, U2 ;
const Handle(Geom2d_Curve) PCurve = BRep_Tool::CurveOnSurface (TopologicalEdge, TopologicalFace, U1, U2) ;
if ( PCurve.IsNull() ) {
return;
}
if ( U1==U2) {
return;
}
//-- Test if a TrimmedCurve is necessary
if( Abs(PCurve->FirstParameter()-U1)<= Precision::PConfusion()
&& Abs(PCurve->LastParameter()-U2)<= Precision::PConfusion()) {
aHatcher.AddElement (PCurve, TopologicalEdge.Orientation()) ;
}
else {
if (!PCurve->IsPeriodic()) {
Handle (Geom2d_TrimmedCurve) TrimPCurve =Handle(Geom2d_TrimmedCurve)::DownCast(PCurve);
if (!TrimPCurve.IsNull()) {
if (TrimPCurve->BasisCurve()->FirstParameter()-U1 > Precision::PConfusion() ||
U2-TrimPCurve->BasisCurve()->LastParameter() > Precision::PConfusion()) {
aHatcher.AddElement (PCurve, TopologicalEdge.Orientation()) ;
return;
}
}
else {
if (PCurve->FirstParameter()-U1 > Precision::PConfusion()){
U1=PCurve->FirstParameter();
}
if (U2-PCurve->LastParameter() > Precision::PConfusion()){
U2=PCurve->LastParameter();
}
}
}
Handle (Geom2d_TrimmedCurve) TrimPCurve = new Geom2d_TrimmedCurve (PCurve, U1, U2) ;
aHatcher.AddElement (TrimPCurve, TopologicalEdge.Orientation()) ;
}
}
//-----------------------------------------------------------------------
// Loading and trimming the hatchings.
//-----------------------------------------------------------------------
Standard_Integer IIso ;
Standard_Real DeltaU = Abs (myUMax - myUMin) ;
Standard_Real DeltaV = Abs (myVMax - myVMin) ;
Standard_Real confusion = Min (DeltaU, DeltaV) * HatcherConfusion3d ;
aHatcher.Confusion3d (confusion) ;
Standard_Real StepU = DeltaU / (Standard_Real) NbIsos ;
if (StepU > confusion) {
Standard_Real UPrm = myUMin + StepU / 2. ;
gp_Dir2d Dir (0., 1.) ;
for (IIso = 1 ; IIso <= NbIsos ; IIso++) {
myUPrm(IIso) = UPrm ;
gp_Pnt2d Ori (UPrm, 0.) ;
Geom2dAdaptor_Curve HCur (new Geom2d_Line (Ori, Dir)) ;
myUInd(IIso) = aHatcher.AddHatching (HCur) ;
UPrm += StepU ;
}
}
Standard_Real StepV = DeltaV / (Standard_Real) NbIsos ;
if (StepV > confusion) {
Standard_Real VPrm = myVMin + StepV / 2. ;
gp_Dir2d Dir (1., 0.) ;
for (IIso = 1 ; IIso <= NbIsos ; IIso++) {
myVPrm(IIso) = VPrm ;
gp_Pnt2d Ori (0., VPrm) ;
Geom2dAdaptor_Curve HCur (new Geom2d_Line (Ori, Dir)) ;
myVInd(IIso) = aHatcher.AddHatching (HCur) ;
VPrm += StepV ;
}
}
//-----------------------------------------------------------------------
// Computation.
//-----------------------------------------------------------------------
aHatcher.Trim() ;
myNbDom = 0 ;
for (IIso = 1 ; IIso <= NbIsos ; IIso++) {
Standard_Integer Index ;
Index = myUInd(IIso) ;
if (Index != 0) {
if (aHatcher.TrimDone (Index) && !aHatcher.TrimFailed (Index)) {
aHatcher.ComputeDomains (Index);
if (aHatcher.IsDone (Index)) myNbDom = myNbDom + aHatcher.NbDomains (Index) ;
}
}
Index = myVInd(IIso) ;
if (Index != 0) {
if (aHatcher.TrimDone (Index) && !aHatcher.TrimFailed (Index)) {
aHatcher.ComputeDomains (Index);
if (aHatcher.IsDone (Index)) myNbDom = myNbDom + aHatcher.NbDomains (Index) ;
}
}
}
//-----------------------------------------------------------------------
// Push iso lines in vtk kernel
//-----------------------------------------------------------------------
Standard_Integer pt_start_idx = 0;
for (Standard_Integer UIso = myUPrm.Lower() ; UIso <= myUPrm.Upper() ; UIso++) {
Standard_Integer UInd = myUInd.Value (UIso) ;
if (UInd != 0) {
Standard_Real UPrm = myUPrm.Value (UIso) ;
if (!aHatcher.IsDone (UInd)) {
MESSAGE("DBRep_IsoBuilder:: U iso of parameter: "<<UPrm)
switch (aHatcher.Status (UInd)) {
case HatchGen_NoProblem : MESSAGE("No Problem") ; break ;
case HatchGen_TrimFailure : MESSAGE("Trim Failure") ; break ;
case HatchGen_TransitionFailure : MESSAGE("Transition Failure") ; break ;
case HatchGen_IncoherentParity : MESSAGE("Incoherent Parity") ; break ;
case HatchGen_IncompatibleStates : MESSAGE("Incompatible States") ; break ;
}
} else {
Standard_Integer NbDom = aHatcher.NbDomains (UInd) ;
for (Standard_Integer IDom = 1 ; IDom <= NbDom ; IDom++) {
const HatchGen_Domain& Dom = aHatcher.Domain (UInd, IDom) ;
Standard_Real V1 = Dom.HasFirstPoint() ? Dom.FirstPoint().Parameter() : myVMin - myInfinite ;
Standard_Real V2 = Dom.HasSecondPoint() ? Dom.SecondPoint().Parameter() : myVMax + myInfinite ;
DrawIso(GeomAbs_IsoU, UPrm, V1, V2, Pts, Cell,pt_start_idx);
}
}
}
}
for (Standard_Integer VIso = myVPrm.Lower() ; VIso <= myVPrm.Upper() ; VIso++) {
Standard_Integer VInd = myVInd.Value (VIso) ;
if (VInd != 0) {
Standard_Real VPrm = myVPrm.Value (VIso) ;
if (!aHatcher.IsDone (VInd)) {
MESSAGE("DBRep_IsoBuilder:: V iso of parameter: "<<VPrm)
switch (aHatcher.Status (VInd)) {
case HatchGen_NoProblem : MESSAGE("No Problem") ; break ;
case HatchGen_TrimFailure : MESSAGE("Trim Failure") ; break ;
case HatchGen_TransitionFailure : MESSAGE("Transition Failure") ; break ;
case HatchGen_IncoherentParity : MESSAGE("Incoherent Parity") ; break ;
case HatchGen_IncompatibleStates : MESSAGE("Incompatible States") ; break ;
}
} else {
Standard_Integer NbDom = aHatcher.NbDomains (VInd) ;
for (Standard_Integer IDom = 1 ; IDom <= NbDom ; IDom++) {
const HatchGen_Domain& Dom = aHatcher.Domain (VInd, IDom) ;
Standard_Real U1 = Dom.HasFirstPoint() ? Dom.FirstPoint().Parameter() : myVMin - myInfinite ;
Standard_Real U2 = Dom.HasSecondPoint() ? Dom.SecondPoint().Parameter() : myVMax + myInfinite ;
DrawIso(GeomAbs_IsoV, VPrm, U1, U2, Pts, Cell,pt_start_idx) ;
}
}
}
}
}
//=======================================================================
// Function : MoveTo
// Purpose : Init VTK ISO PLOT
//=======================================================================
void GEOM_OCCReader::MoveTo(gp_Pnt P,
vtkPoints* Pts)
{
float coord[3];
coord[0] = P.X(); coord[1] = P.Y(); coord[2] = P.Z();
lastVTKpoint = Pts->InsertNextPoint(coord);
}
//=======================================================================
// Function : DrawTo
// Purpose : Plot point in VTK
//=======================================================================
void GEOM_OCCReader::DrawTo(gp_Pnt P,
vtkPoints* Pts,
vtkCellArray* Cells)
{
float coord[3];
coord[0] = P.X(); coord[1] = P.Y(); coord[2] = P.Z();
Standard_Integer NewVTKpoint = Pts->InsertNextPoint(coord);
int pts[2];
pts[0] = lastVTKpoint;
pts[1] = NewVTKpoint;
Cells->InsertNextCell(2,pts);
lastVTKpoint = NewVTKpoint;
}
//=======================================================================
// Function : DrawIso
// Purpose : Draw an iso on vtk
//=======================================================================
void GEOM_OCCReader::DrawIso(GeomAbs_IsoType T,
Standard_Real Par,
Standard_Real T1,
Standard_Real T2,
vtkPoints* Pts,
vtkCellArray* Cells,
Standard_Integer& startidx)
{
Standard_Boolean halt = Standard_False;
Standard_Integer j,myDiscret = discretiso;
Standard_Real U1,U2,V1,V2,stepU=0.,stepV=0.;
gp_Pnt P;
TopLoc_Location l;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(TopoDS::Face(myShape),l);
if (!S.IsNull()) {
BRepAdaptor_Surface S(TopoDS::Face(myShape),Standard_False);
GeomAbs_SurfaceType SurfType = S.GetType();
GeomAbs_CurveType CurvType = GeomAbs_OtherCurve;
Standard_Integer Intrv, nbIntv;
Standard_Integer nbUIntv = S.NbUIntervals(GeomAbs_CN);
Standard_Integer nbVIntv = S.NbVIntervals(GeomAbs_CN);
TColStd_Array1OfReal TI(1,Max(nbUIntv, nbVIntv)+1);
if (T == GeomAbs_IsoU) {
S.VIntervals(TI, GeomAbs_CN);
V1 = Max(T1, TI(1));
V2 = Min(T2, TI(2));
U1 = Par;
U2 = Par;
stepU = 0;
nbIntv = nbVIntv;
}
else {
S.UIntervals(TI, GeomAbs_CN);
U1 = Max(T1, TI(1));
U2 = Min(T2, TI(2));
V1 = Par;
V2 = Par;
stepV = 0;
nbIntv = nbUIntv;
}
S.D0(U1,V1,P);
MoveTo(P,Pts);
for (Intrv = 1; Intrv <= nbIntv; Intrv++) {
if (TI(Intrv) <= T1 && TI(Intrv + 1) <= T1)
continue;
if (TI(Intrv) >= T2 && TI(Intrv + 1) >= T2)
continue;
if (T == GeomAbs_IsoU) {
V1 = Max(T1, TI(Intrv));
V2 = Min(T2, TI(Intrv + 1));
stepV = (V2 - V1) / myDiscret;
}
else {
U1 = Max(T1, TI(Intrv));
U2 = Min(T2, TI(Intrv + 1));
stepU = (U2 - U1) / myDiscret;
}
switch (SurfType) {
//-------------GeomAbs_Plane---------------
case GeomAbs_Plane :
break;
//----GeomAbs_Cylinder GeomAbs_Cone------
case GeomAbs_Cylinder :
case GeomAbs_Cone :
if (T == GeomAbs_IsoV) {
for (j = 1; j < myDiscret; j++) {
U1 += stepU;
V1 += stepV;
S.D0(U1,V1,P);
DrawTo(P,Pts,Cells);
}
}
break;
//---GeomAbs_Sphere GeomAbs_Torus--------
//GeomAbs_BezierSurface GeomAbs_BezierSurface
case GeomAbs_Sphere :
case GeomAbs_Torus :
case GeomAbs_OffsetSurface :
case GeomAbs_OtherSurface :
for (j = 1; j < myDiscret; j++) {
U1 += stepU;
V1 += stepV;
S.D0(U1,V1,P);
DrawTo(P,Pts,Cells);
}
break;
//-------------GeomAbs_BSplineSurface------
case GeomAbs_BezierSurface :
case GeomAbs_BSplineSurface :
for (j = 1; j <= myDiscret/2; j++) {
PlotCount = 0;
PlotIso ( S, T, U1, V1, (T == GeomAbs_IsoV) ? stepU*2. : stepV*2., halt, Pts, Cells);
U1 += stepU*2.;
V1 += stepV*2.;
}
break;
//-------------GeomAbs_SurfaceOfExtrusion--
//-------------GeomAbs_SurfaceOfRevolution-
case GeomAbs_SurfaceOfExtrusion :
case GeomAbs_SurfaceOfRevolution :
if ((T == GeomAbs_IsoV && SurfType == GeomAbs_SurfaceOfRevolution) ||
(T == GeomAbs_IsoU && SurfType == GeomAbs_SurfaceOfExtrusion)) {
if (SurfType == GeomAbs_SurfaceOfExtrusion) break;
for (j = 1; j < myDiscret; j++) {
U1 += stepU;
V1 += stepV;
S.D0(U1,V1,P);
DrawTo(P,Pts,Cells);
}
} else {
CurvType = (S.BasisCurve())->GetType();
switch (CurvType) {
case GeomAbs_Line :
break;
case GeomAbs_Circle :
case GeomAbs_Ellipse :
for (j = 1; j < myDiscret; j++) {
U1 += stepU;
V1 += stepV;
S.D0(U1,V1,P);
DrawTo(P,Pts,Cells);
}
break;
case GeomAbs_Parabola :
case GeomAbs_Hyperbola :
case GeomAbs_BezierCurve :
case GeomAbs_BSplineCurve :
case GeomAbs_OtherCurve :
for (j = 1; j <= myDiscret/2; j++) {
PlotCount = 0;
PlotIso ( S, T, U1, V1,(T == GeomAbs_IsoV) ? stepU*2. : stepV*2., halt, Pts, Cells);
U1 += stepU*2.;
V1 += stepV*2.;
}
break;
}
}
}
}
S.D0(U2,V2,P);
DrawTo(P,Pts,Cells);
}
}
//=======================================================================
// Function : PlotIso
// Purpose : Plot iso for other surface
//=======================================================================
void GEOM_OCCReader::PlotIso (BRepAdaptor_Surface& S,
GeomAbs_IsoType T,
Standard_Real& U,
Standard_Real& V,
Standard_Real Step,
Standard_Boolean& halt,
vtkPoints* Pts,
vtkCellArray* Cells)
{
++PlotCount;
gp_Pnt Pl, Pr, Pm;
if (T == GeomAbs_IsoU) {
S.D0(U, V, Pl);
S.D0(U, V + Step/2., Pm);
S.D0(U, V + Step, Pr);
} else {
S.D0(U, V, Pl);
S.D0(U + Step/2., V, Pm);
S.D0(U + Step, V, Pr);
}
if (PlotCount > MaxPlotCount) {
DrawTo(Pr,Pts,Cells);
return;
}
if (Pm.Distance(Pl) + Pm.Distance(Pr) <= IsoRatio*Pl.Distance(Pr)) {
DrawTo(Pr,Pts,Cells);
} else
if (T == GeomAbs_IsoU) {
PlotIso ( S, T, U, V, Step/2, halt, Pts, Cells);
Standard_Real aLocalV = V + Step/2 ;
PlotIso ( S, T, U, aLocalV , Step/2, halt, Pts, Cells);
} else {
PlotIso ( S, T, U, V, Step/2, halt, Pts, Cells);
Standard_Real aLocalU = U + Step/2 ;
PlotIso ( S, T, aLocalU , V, Step/2, halt, Pts, Cells);
}
}
//=======================================================================
// Function : TransferEdgeWData
// Purpose : Transfert wireframe data for EDGE
//=======================================================================
void GEOM_OCCReader::TransferEdgeWData(const TopoDS_Edge& aEdge,
vtkPoints* Pts,
vtkCellArray* Cells) {
Handle(Poly_PolygonOnTriangulation) aEdgePoly;
Standard_Integer i = 1;
Handle(Poly_Triangulation) T;
TopLoc_Location aEdgeLoc;
BRep_Tool::PolygonOnTriangulation(aEdge, aEdgePoly, T, aEdgeLoc, i);
Handle(Poly_Polygon3D) P;
if(aEdgePoly.IsNull()) {
P = BRep_Tool::Polygon3D(aEdge, aEdgeLoc);
}
if(P.IsNull() && aEdgePoly.IsNull())
return;
// Location edges
//---------------
gp_Trsf edgeTransf;
Standard_Boolean isidtrsf = true;
if(!aEdgeLoc.IsIdentity()) {
isidtrsf = false;
edgeTransf = aEdgeLoc.Transformation();
}
Standard_Integer nbnodes;
if (aEdgePoly.IsNull()) {
nbnodes = P->NbNodes();
const TColgp_Array1OfPnt& theNodesP = P->Nodes();
float coord[3];
int pts[2];
for(int j=1;j<nbnodes;j++) {
gp_Pnt pt1 = theNodesP(j);
gp_Pnt pt2 = theNodesP(j+1);
if(!isidtrsf) {
// apply edge transformation
pt1.Transform(edgeTransf);
pt2.Transform(edgeTransf);
}
// insert pt1
coord[0] = pt1.X(); coord[1] = pt1.Y(); coord[2] = pt1.Z();
pts[0] = Pts->InsertNextPoint(coord);
// insert pt2
coord[0] = pt2.X(); coord[1] = pt2.Y(); coord[2] = pt2.Z();
pts[1] = Pts->InsertNextPoint(coord);
// insert line (pt1,pt2)
Cells->InsertNextCell(2,pts);
}
} else {
nbnodes = aEdgePoly->NbNodes();
const TColStd_Array1OfInteger& Nodesidx = aEdgePoly->Nodes();
const TColgp_Array1OfPnt& theNodesPoly = T->Nodes();
float coord[3];
int pts[2];
for(int j=1;j<nbnodes;j++) {
Standard_Integer id1 = Nodesidx(j);
Standard_Integer id2 = Nodesidx(j+1);
gp_Pnt pt1 = theNodesPoly(id1);
gp_Pnt pt2 = theNodesPoly(id2);
if(!isidtrsf) {
// apply edge transformation
pt1.Transform(edgeTransf);
pt2.Transform(edgeTransf);
}
// insert pt1
coord[0] = pt1.X(); coord[1] = pt1.Y(); coord[2] = pt1.Z();
pts[0] = Pts->InsertNextPoint(coord);
// insert pt2
coord[0] = pt2.X(); coord[1] = pt2.Y(); coord[2] = pt2.Z();
pts[1] = Pts->InsertNextPoint(coord);
// insert line (pt1,pt2)
Cells->InsertNextCell(2,pts);
}
}
}
/* Standard_Integer nbnodes = aEdgePoly->NbNodes();
const TColStd_Array1OfInteger& Nodesidx = aEdgePoly->Nodes();
const TColgp_Array1OfPnt& theNodes = T->Nodes();
float coord[3];
int pts[2];
// PUSH NODES
for(i=1;i<=nbnodes;i++) {
Standard_Integer id = Nodesidx(i);
gp_Pnt pt = theNodes(id);
float coord[3];
if(!isidtrsf) pt.Transform(edgeTransf);
coord[0] = pt.X(); coord[1] = pt.Y(); coord[2] = pt.Z();
Pts->SetPoint(id-1,coord);
}
// PUSH EDGES
for(i=1;i<nbnodes;i++) {
Standard_Integer id1 = Nodesidx(i);
Standard_Integer id2 = Nodesidx(i+1);
int pts[2];
pts[0] = id1-1; pts[1] = id2-1;
// insert line (pt1,pt2)
Cells->InsertNextCell(2,pts);
}
}*/
//=======================================================================
// Function : TransferVertexWData
// Purpose : Transfert wireframe data for VERTEX
//=======================================================================
void GEOM_OCCReader::TransferVertexWData(const TopoDS_Vertex& aVertex,
vtkPoints* Pts,
vtkCellArray* Cells) {
#define ZERO_COORD coord[0] = 0.0; coord[1] = 0.0; coord[2] = 0.0
gp_Pnt P = BRep_Tool::Pnt( aVertex );
float delta = 1, coord[3];
int pts[2];
// insert pt
ZERO_COORD; coord[0] = +delta;
pts[0] = Pts->InsertNextPoint(coord);
coord[0] = -delta;
pts[1] = Pts->InsertNextPoint(coord);
// insert line (pt1,pt2)
Cells->InsertNextCell(2,pts);
ZERO_COORD; coord[1] = +delta;
pts[0] = Pts->InsertNextPoint(coord);
coord[1] = -delta;
pts[1] = Pts->InsertNextPoint(coord);
// insert line (pt1,pt2)
Cells->InsertNextCell(2,pts);
ZERO_COORD; coord[2] = +delta;
pts[0] = Pts->InsertNextPoint(coord);
coord[2] = -delta;
pts[1] = Pts->InsertNextPoint(coord);
// insert line (pt1,pt2)
Cells->InsertNextCell(2,pts);
#undef ZERO_COORD
}
//=======================================================================
// Function : TransferEdgeSData(
// Purpose : Transfert shading data for EDGE
//=======================================================================
void GEOM_OCCReader::TransferEdgeSData(const TopoDS_Edge& aFace,
vtkPoints* Pts,
vtkCellArray* Cells)
{
}
//=======================================================================
// Function : TransferFaceSData
// Purpose : Transfert shading data for FACE
//=======================================================================
void GEOM_OCCReader::TransferFaceSData(const TopoDS_Face& aFace,
vtkPoints* Pts,
vtkCellArray* Cells) {
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
if(aPoly.IsNull()) return;
else {
gp_Trsf myTransf;
Standard_Boolean identity = true;
if(!aLoc.IsIdentity()) {
identity = false;
myTransf = aLoc.Transformation();
}
Standard_Integer nbNodesInFace = aPoly->NbNodes();
Standard_Integer nbTriInFace = aPoly->NbTriangles();
const Poly_Array1OfTriangle& Triangles = aPoly->Triangles();
const TColgp_Array1OfPnt& Nodes = aPoly->Nodes();
Standard_Integer i;
for(i=1;i<=nbNodesInFace;i++) {
gp_Pnt P = Nodes(i);
float coord[3];
if(!identity) P.Transform(myTransf);
coord[0] = P.X(); coord[1] = P.Y(); coord[2] = P.Z();
Pts->SetPoint(i-1,coord);
}
for(i=1;i<=nbTriInFace;i++) {
// Get the triangle
Standard_Integer N1,N2,N3;
Triangles(i).Get(N1,N2,N3);
int pts[3];
pts[0] = N1-1; pts[1] = N2-1; pts[2] = N3-1;
Cells->InsertNextCell(3,pts);
}
}
}
//=======================================================================
// Function : ComputeShading
// Purpose : Compute the shape in shading mode
//=======================================================================
void GEOM_OCCReader::ComputeShading(vtkPoints* Pts,vtkCellArray* Cells){
// Check the type of the shape:
if(myShape.ShapeType() == TopAbs_FACE) {
// Face
TransferFaceSData(TopoDS::Face(myShape),Pts,Cells);
}
else {
if(myShape.ShapeType() == TopAbs_EDGE) {
// Edge
TransferEdgeSData(TopoDS::Edge(myShape),Pts,Cells);
}
else {
}
}
}
//=======================================================================
// Function :
// Purpose : Set parameters
//=======================================================================
void GEOM_OCCReader::setDisplayMode(int thenewmode) {
amode = thenewmode;
}
void GEOM_OCCReader::setTopo(const TopoDS_Shape& aShape) {
myShape = aShape;
}
void GEOM_OCCReader::setForceUpdate(Standard_Boolean bol) {
forced = bol;
}
//=======================================================================
// Function :
// Purpose : Get parameters
//=======================================================================
const TopoDS_Shape& GEOM_OCCReader::getTopo() {
return myShape;
}
int GEOM_OCCReader::getDisplayMode() {
return amode;
}

View File

@ -1,140 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_OCCReader.h
// Author : Christophe ATTANASIO
// Module : GEOM
// $Header$
/*!
\class GEOM_OCCReader GEOM_OCCReader.h
\brief This class allow to display a OpenCASCADE CAD model in a VTK viewer.
*/
#ifndef GEOM_OCCREADER_H
#define GEOM_OCCREADER_H
// VTK
#include "VTKViewer_Common.h"
// OpenCASCADE
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <GeomAbs_IsoType.hxx>
#include <BRepAdaptor_Surface.hxx>
#ifdef _WIN_32
#define VTKOCC_EXPORT __declspec (dllexport)
#else
#define VTKOCC_EXPORT
#endif
class VTKOCC_EXPORT GEOM_OCCReader : public vtkPolyDataSource {
// methods
public:
static GEOM_OCCReader* New();
const TopoDS_Shape& getTopo();
void setTopo(const TopoDS_Shape& ashape);
int getDisplayMode();
void setDisplayMode(int);
void setForceUpdate(Standard_Boolean bol);
protected:
GEOM_OCCReader();
~GEOM_OCCReader();
void Execute();
void ComputeShading(vtkPoints* Pts,vtkCellArray* Cells);
void ComputeWireframe(vtkPoints* Pts,vtkCellArray* Cells);
void TransferFaceSData(const TopoDS_Face& aFace,
vtkPoints* Pts,
vtkCellArray* Cells);
void TransferFaceWData(const TopoDS_Face& aFace,
vtkPoints* Pts,
vtkCellArray* Cells);
void TransferEdgeSData(const TopoDS_Edge& aEdge,
vtkPoints* Pts,
vtkCellArray* Cells);
void TransferEdgeWData(const TopoDS_Edge& aEdge,
vtkPoints* Pts,
vtkCellArray* Cells);
void TransferVertexWData(const TopoDS_Vertex& aVertex,
vtkPoints* Pts,
vtkCellArray* Cells);
void createISO(const TopoDS_Face &,
double, int,
vtkPoints* Pts,
vtkCellArray* Cells);
void DrawIso(GeomAbs_IsoType aType,
Standard_Real PParm,
Standard_Real p1,
Standard_Real p2,
vtkPoints* Pts,
vtkCellArray* Cells,
Standard_Integer& startidx);
void MoveTo(gp_Pnt P,
vtkPoints* Pts);
void DrawTo(gp_Pnt P,
vtkPoints* Pts,
vtkCellArray* Cells);
void PlotIso(BRepAdaptor_Surface& S,
GeomAbs_IsoType T,
Standard_Real& U,
Standard_Real& V,
Standard_Real Step,
Standard_Boolean& halt,
vtkPoints* Pts,
vtkCellArray* Cells);
// fields
private:
Standard_Boolean forced;
int discretiso;
int amode;
int nbisos;
TopoDS_Shape myShape;
};
#endif //GEOM_OCCREADER_H

View File

@ -1,100 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Handle_GEOM_AISShape.hxx
// Module : GEOM
#ifndef _Handle_GEOM_AISShape_HeaderFile
#define _Handle_GEOM_AISShape_HeaderFile
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_AISShape_HeaderFile
#include "Handle_SALOME_AISShape.hxx"
#endif
class Standard_Transient;
class Handle_Standard_Type;
class Handle(SALOME_AISShape);
class GEOM_AISShape;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_AISShape);
class Handle(GEOM_AISShape) : public Handle(SALOME_AISShape) {
public:
inline void* operator new(size_t,void* anAddress)
{
return anAddress;
}
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
}
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// inline void operator delete(void *anAddress, size_t size)
// {
// if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
// }
Handle(GEOM_AISShape)():Handle(SALOME_AISShape)() {}
Handle(GEOM_AISShape)(const Handle(GEOM_AISShape)& aHandle) : Handle(SALOME_AISShape)(aHandle)
{
}
Handle(GEOM_AISShape)(const GEOM_AISShape* anItem) : Handle(SALOME_AISShape)((SALOME_AISShape *)anItem)
{
}
Handle(GEOM_AISShape)& operator=(const Handle(GEOM_AISShape)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(GEOM_AISShape)& operator=(const GEOM_AISShape* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
GEOM_AISShape* operator->()
{
return (GEOM_AISShape *)ControlAccess();
}
GEOM_AISShape* operator->() const
{
return (GEOM_AISShape *)ControlAccess();
}
Standard_EXPORT ~Handle(GEOM_AISShape)();
Standard_EXPORT static const Handle(GEOM_AISShape) DownCast(const Handle(Standard_Transient)& AnObject);
};
#endif

View File

@ -1,100 +0,0 @@
// GEOM OBJECT : interactive object for Geometry entities visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Handle_GEOM_InteractiveObject.hxx
// Module : GEOM
#ifndef _Handle_GEOM_InteractiveObject_HeaderFile
#define _Handle_GEOM_InteractiveObject_HeaderFile
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
#include "Handle_SALOME_InteractiveObject.hxx"
#endif
class Standard_Transient;
class Handle_Standard_Type;
class Handle(SALOME_InteractiveObject);
class GEOM_InteractiveObject;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_InteractiveObject);
class Handle(GEOM_InteractiveObject) : public Handle(SALOME_InteractiveObject) {
public:
inline void* operator new(size_t,void* anAddress)
{
return anAddress;
}
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
}
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// inline void operator delete(void *anAddress, size_t size)
// {
// if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
// }
Handle(GEOM_InteractiveObject)():Handle(SALOME_InteractiveObject)() {}
Handle(GEOM_InteractiveObject)(const Handle(GEOM_InteractiveObject)& aHandle) : Handle(SALOME_InteractiveObject)(aHandle)
{
}
Handle(GEOM_InteractiveObject)(const GEOM_InteractiveObject* anItem) : Handle(SALOME_InteractiveObject)((SALOME_InteractiveObject *)anItem)
{
}
Handle(GEOM_InteractiveObject)& operator=(const Handle(GEOM_InteractiveObject)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(GEOM_InteractiveObject)& operator=(const GEOM_InteractiveObject* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
GEOM_InteractiveObject* operator->()
{
return (GEOM_InteractiveObject *)ControlAccess();
}
GEOM_InteractiveObject* operator->() const
{
return (GEOM_InteractiveObject *)ControlAccess();
}
Standard_EXPORT ~Handle(GEOM_InteractiveObject)();
Standard_EXPORT static const Handle(GEOM_InteractiveObject) DownCast(const Handle(Standard_Transient)& AnObject);
};
#endif

View File

@ -1,65 +0,0 @@
# GEOM OBJECT : interactive object for Geometry entities visualization
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Module : GEOM
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
EXPORT_HEADERS = GEOM_Actor.h \
GEOM_AssemblyBuilder.h \
GEOM_AISShape.hxx \
Handle_GEOM_AISShape.hxx \
GEOM_InteractiveObject.hxx \
Handle_GEOM_InteractiveObject.hxx
# Libraries targets
LIB = libGeometryObject.la
LIB_SRC = GEOM_Actor.cxx \
GEOM_OCCReader.cxx \
GEOM_AssemblyBuilder.cxx \
GEOM_AISShape.cxx \
GEOM_InteractiveObject.cxx
LIB_CLIENT_IDL =
# Executables targets
BIN =
BIN_SRC =
CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES)
LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) -lSalomeObject
%_moc.cxx: %.h
$(MOC) $< -o $@
@CONCLUDE@

View File

@ -1,63 +0,0 @@
# GEOM PARTITION : partition algorithm
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Author : Marc Tajchman (CEA)
# Module : GEOM
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
VPATH=.:@srcdir@
@COMMENCE@
# Libraries targets
LIB = libGeometryPartition.la
LIB_SRC = Partition_Inter2d.cxx \
Partition_Inter3d.cxx \
Partition_Loop2d.cxx \
Partition_Loop3d.cxx \
Partition_Spliter.cxx
LIB_CLIENT_IDL =
LIB_SERVER_IDL =
# header files
EXPORT_HEADERS = Partition_Spliter.hxx \
Partition_Inter3d.hxx
# idl files
EXPORT_IDLS=
CPPFLAGS += $(OCC_INCLUDES)
CXXFLAGS += $(OCC_CXXFLAGS)
LDFLAGS += $(OCC_LIBS)
%_moc.cxx: %.h
$(MOC) $< -o $@
@CONCLUDE@

View File

@ -1,44 +0,0 @@
-- GEOM PARTITION : partition algorithm
--
-- Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
--
--
--
-- File : Partition.cdl
-- Author : Benedicte MARTIN
-- Module : GEOM
package Partition
uses
TopoDS,
TopTools,
TopAbs,
BRepAlgo,
BRep,
gp
is
class Spliter;
class Inter3d;
class Inter2d;
class Loop2d;
class Loop3d;
end Partition;

View File

@ -1,74 +0,0 @@
-- GEOM PARTITION : partition algorithm
--
-- Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
--
--
--
-- File : Partition_Inter2d.cdl
-- Author : Benedicte MARTIN
-- Module : GEOM
class Inter2d from Partition
---Purpose: Computes the intersections between edges on a face
-- stores result is SD as AsDes from BRepAlgo.
uses
AsDes from BRepAlgo,
Edge from TopoDS,
Face from TopoDS,
Vertex from TopoDS,
MapOfShape from TopTools,
Real from Standard,
ListOfShape from TopTools
is
CompletPart2d(myclass ; AsDes : mutable AsDes from BRepAlgo;
F : Face from TopoDS;
NewEdges : MapOfShape from TopTools);
---Purpose: Computes the intersections between the edges stored
-- is AsDes as descendants of <F> . Intersections is computed
-- between two edges if one of them is bound in NewEdges.
FindEndVertex(myclass; VertList : ListOfShape from TopTools;
f,l : Real from Standard;
E : Edge from TopoDS;
First : out Boolean from Standard;
DU : out Real from Standard)
returns Vertex from TopoDS;
---Purpose: Returns a vertex from <VertList> having parameter on
-- <E> most close to <f> or <l>. <First> is True if
-- found vertex is closer to <f>. <DU> returns parameter
-- difference.
AddVonE(myclass; V : Vertex from TopoDS;
E1,E2 : Edge from TopoDS;
AsDes : mutable AsDes from BRepAlgo)
returns Vertex from TopoDS;
---Purpose: Put V in AsDes as intersection of E1 and E2.
-- Check that vertex equal to V already exists on one
-- of edges, in such a case, V is not added but
-- existing vertex is updated to be on E1 and E2 and
-- is returned insead of V.
end Inter2d;

View File

@ -1,545 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Inter2d.cxx
// Author : Benedicte MARTIN
// Module : GEOM
// $Header$
using namespace std;
#include "Partition_Inter2d.ixx"
#include "utilities.h"
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepAlgo_AsDes.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepLib_MakeVertex.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopOpeBRep_EdgesIntersector.hxx>
#include <TopOpeBRep_Point2d.hxx>
#include <TopOpeBRepDS_Transition.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <stdio.h>
#include <Precision.hxx>
#ifdef DEB
static Standard_Boolean TestEdges = 0;
static Standard_Integer NbF2d = 0;
static Standard_Integer NbE2d = 0;
#endif
//=======================================================================
//function : StorePart2d
//purpose :
//=======================================================================
// static void StorePart2d (const TopoDS_Edge& E1,
// const TopoDS_Edge& E2,
// TopTools_ListOfShape& LV1,
// TopTools_ListOfShape& LV2,
// Handle(BRepAlgo_AsDes) AsDes,
// Standard_Real Tol)
TopoDS_Vertex Partition_Inter2d::AddVonE(const TopoDS_Vertex& theV,
const TopoDS_Edge& E1,
const TopoDS_Edge& E2,
const Handle(BRepAlgo_AsDes)& AsDes)
{
//-------------------------------------------------------------
// test if the points of intersection already exist. If not,
// add as descendants of the edges.
// nb: theses points are only vertices of intersection.
//-------------------------------------------------------------
const TopTools_ListOfShape& VOnE1 = AsDes->Descendant(E1);
const TopTools_ListOfShape& VOnE2 = AsDes->Descendant(E2);
TopTools_ListOfShape NewVOnE1;
TopTools_ListOfShape NewVOnE2;
gp_Pnt P1,P2;
TopoDS_Vertex V1,V2;
TopTools_ListIteratorOfListOfShape it, itLV1, itLV2;
BRep_Builder B;
TopAbs_Orientation O1,O2;
Standard_Real U1,U2;
Standard_Real Tol,Tol1,Tol2;
Standard_Boolean OnE1,OnE2;
// for (itLV1.Initialize(LV1),itLV2.Initialize(LV2);
// itLV1.More();
// itLV1.Next() ,itLV2.Next()) {
TopoDS_Vertex V = theV;
// TopoDS_Vertex V = TopoDS::Vertex(itLV1.Value());
U1 = BRep_Tool::Parameter(V,E1);
U2 = BRep_Tool::Parameter(V,E2);
O1 = V.Orientation();
O2 = O1;///itLV2.Value().Orientation();
P1 = BRep_Tool::Pnt(V);
Tol = BRep_Tool::Tolerance( V );
OnE1 = OnE2 = Standard_False;
//-----------------------------------------------------------------
// Search if the point of intersection is a vertex of E1.
//-----------------------------------------------------------------
for (it.Initialize(VOnE1); it.More(); it.Next()) {
const TopoDS_Vertex& CV = TopoDS::Vertex( it.Value() );
if (V.IsSame( CV )) {
V1 = V;
OnE1 = Standard_True;
break;
}
P2 = BRep_Tool::Pnt( CV );
Tol1 = 1.1*(Tol + BRep_Tool::Tolerance( CV ));
if (P1.SquareDistance(P2) <= Tol1*Tol1) {
V = CV;
V1 = V;
OnE1 = Standard_True;
break;
}
}
if (OnE1) {
//-----------------------------------------------------------------
// Search if the vertex found is still on E2.
//-----------------------------------------------------------------
for (it.Initialize(VOnE2); it.More(); it.Next()) {
if (V.IsSame( it.Value() )) {
OnE2 = Standard_True;
V2 = V;
break;
}
}
}
if (!OnE2) {
for (it.Initialize(VOnE2); it.More(); it.Next()) {
//-----------------------------------------------------------------
// Search if the point of intersection is a vertex of E2.
//-----------------------------------------------------------------
const TopoDS_Vertex& CV = TopoDS::Vertex( it.Value() );
P2 = BRep_Tool::Pnt( CV );
Tol2 = 1.1*(Tol + BRep_Tool::Tolerance( CV ));
if (P1.SquareDistance(P2) <= Tol2*Tol2) {
V = CV;
V2 = V;
OnE2 = Standard_True;
break;
}
}
}
if (OnE1 && OnE2) {
if (!V1.IsSame(V2)) {
Standard_Real UV2;
TopoDS_Edge EWE2;
TopoDS_Vertex VI;
const TopTools_ListOfShape& EdgeWithV2 = AsDes->Ascendant(V2);
for (it.Initialize(EdgeWithV2); it.More(); it.Next()) {
EWE2 = TopoDS::Edge(it.Value());
VI = V2;
VI.Orientation(TopAbs_INTERNAL);
UV2 = BRep_Tool::Parameter(VI,EWE2);
VI = V1;
VI.Orientation(TopAbs_INTERNAL);
B.UpdateVertex(VI,UV2,EWE2, Max(Tol1,Tol2));
}
AsDes->Replace(V2,V1);
}
}
// add existing vertices instead of new ones
if (!OnE1) {
if (OnE2) {
V.Orientation(TopAbs_INTERNAL);
B.UpdateVertex(V,U1,E1, Tol2);
}
V.Orientation(O1);
NewVOnE1.Prepend(V);
}
if (!OnE2) {
if (OnE1) {
V.Orientation(TopAbs_INTERNAL);
B.UpdateVertex(V,U2,E2, Tol1);
}
V.Orientation(O2);
NewVOnE2.Prepend(V);
}
// }
if (!NewVOnE1.IsEmpty()) AsDes->Add(E1,NewVOnE1);
if (!NewVOnE2.IsEmpty()) AsDes->Add(E2,NewVOnE2);
return V;
}
//=======================================================================
//function : FindEndVertex
//purpose : Returns a vertex from <VertList> having parameter on
// <E> closest to <f> or <l>. <isFirst> is True if
// found vertex is closer to <f>. <DU> returns parameter
// difference.
//=======================================================================
TopoDS_Vertex Partition_Inter2d::FindEndVertex(const TopTools_ListOfShape& LV,
const Standard_Real f,
const Standard_Real l,
const TopoDS_Edge& E,
Standard_Boolean& isFirst,
Standard_Real& minDU)
{
TopoDS_Vertex endV;
Standard_Real U, endU, min;
minDU = 1.e10;
TopTools_ListIteratorOfListOfShape it;
it.Initialize(LV);
for (; it.More(); it.Next()) {
const TopoDS_Vertex& v = TopoDS::Vertex(it.Value());
U = BRep_Tool::Parameter(v, E);
min = Min( Abs(U-f), Abs(U-l) );
if (min < minDU) {
endV = v;
endU = U;
minDU = min;
}
}
if (Abs(endU-f) < Abs(endU-l))
isFirst = Standard_True;
else
isFirst = Standard_False;
return endV;
}
//=======================================================================
//function : treatClosed
//purpose : add second vertex to closed edge. Vertex is one of <LV1>
//=======================================================================
static void treatClosed (const TopoDS_Edge& E1,
const Standard_Real f,
const Standard_Real l,
TopTools_ListOfShape& LV1,
TopTools_ListOfShape& /*LV2*/)
{
Standard_Boolean isFirst=0;
Standard_Real minDU = 1.e10;
TopoDS_Vertex endV;
endV = Partition_Inter2d::FindEndVertex(LV1, f,l, E1, isFirst,minDU);
if (minDU > Precision::PConfusion())
return; // not end point
Standard_Real newU;
if (isFirst)
newU = f + (l - f);
else
newU = l - (l - f);
// update end parameter
BRep_Builder B;
endV.Orientation(TopAbs_INTERNAL);
B.UpdateVertex(endV,newU,E1,BRep_Tool::Tolerance(endV));
}
//=======================================================================
//function : EdgesPartition
//purpose :
//=======================================================================
static void EdgesPartition(const TopoDS_Face& F,
const TopoDS_Edge& E1,
const TopoDS_Edge& E2,
const Handle(BRepAlgo_AsDes)& AsDes,
const TopTools_MapOfShape& NewEdges,
const Standard_Boolean WithOri)
{
Standard_Real f[3],l[3];
Standard_Real MilTol2;
Standard_Real Tol = Max (BRep_Tool::Tolerance(E1),
BRep_Tool::Tolerance(E2));
MilTol2 = Tol * Tol * 10;
BRep_Tool::Range(E1, f[1], l[1]);
BRep_Tool::Range(E2, f[2], l[2]);
BRepAdaptor_Curve CE1(E1,F);
BRepAdaptor_Curve CE2(E2,F);
TopoDS_Edge EI[3]; EI[1] = E1; EI[2] = E2;
TopTools_ListOfShape LV1; // new vertices at intersections on E1
TopTools_ListOfShape LV2; // ... on E2
BRep_Builder B;
// if E1 and E2 are results of intersection of F and two connex faces then
// no need to intersect edges, they can contact by vertices only
// (encounted an exception in TopOpeBRep_EdgesIntersector in such a case)
Standard_Boolean intersect = Standard_True;
TopTools_IndexedMapOfShape ME;
TopExp::MapShapes(F, TopAbs_EDGE, ME);
if (!ME.Contains(E1) && ! ME.Contains(E2)) { // if E1 and E2 are new on F
TopoDS_Shape F1, F2;
const TopTools_ListOfShape& LF1 = AsDes->Ascendant( E1 );
F1 = F.IsSame( LF1.First() ) ? LF1.Last() : LF1.First();
const TopTools_ListOfShape& LF2 = AsDes->Ascendant( E2 );
F2 = F.IsSame( LF2.First() ) ? LF2.Last() : LF2.First();
if (!F.IsSame(F2) && !F.IsSame(F1) ) {
TopExp_Explorer exp(F2, TopAbs_EDGE);
TopExp::MapShapes(F1, TopAbs_EDGE, ME);
for (; exp.More(); exp.Next()) {
if (ME.Contains( exp.Current())) {
intersect = Standard_False;
break;
}
}
}
}
if (intersect) {
//------------------------------------------------------
// compute the points of Intersection in 2D
//-----------------------------------------------------
// i.e. fill LV1 and LV2
TopOpeBRep_EdgesIntersector EInter;
EInter.SetFaces(F,F);
Standard_Real TolDub = 1.e-7;
EInter.ForceTolerances(TolDub,TolDub);
Standard_Boolean reducesegments = Standard_False;
EInter.Perform (E1,E2,reducesegments);
Standard_Boolean rejectreducedsegmentpoints = Standard_False;
EInter.InitPoint(rejectreducedsegmentpoints);
for (;EInter.MorePoint();EInter.NextPoint()) {
const TopOpeBRep_Point2d& P2D = EInter.Point();
const gp_Pnt& P = P2D.Value();
TopoDS_Vertex V = BRepLib_MakeVertex(P);
//-------------------------
// control the point found.
//-------------------------
gp_Pnt P1 = CE1.Value(P2D.Parameter(1));
gp_Pnt P2 = CE2.Value(P2D.Parameter(2));
Standard_Real sqd1 = P1.SquareDistance(P);
Standard_Real sqd2 = P2.SquareDistance(P);
if (sqd1 > MilTol2 || sqd2 > MilTol2 ) {
//MESSAGE ( "Inter2d : Solution rejected, dist: " << sqrt(Max(sqd1,sqd2)) )
#ifdef DEB
if (TestEdges) {
MESSAGE ( " edges : E2d_"<<NbE2d-2<<" E2d_"<<NbE2d-1 ); }
#endif
continue;
}
// add a new vertex to the both edges
Standard_Real toler = 1.5 * Max (Tol, sqrt(Max(sqd1,sqd2)) );
Standard_Integer i;
for (i = 1; i <= 2; i++) {
Standard_Real U = P2D.Parameter(i);
#ifdef DEB
if (U < f[i]-Tol || U > l[i]+Tol) {
MESSAGE ( "out" );
}
#endif
V.Orientation(TopAbs_INTERNAL);
B.UpdateVertex( V,U,EI[i], toler);
TopAbs_Orientation OO = TopAbs_REVERSED;
if (WithOri) {
if (P2D.IsVertex(i))
OO = P2D.Vertex(i).Orientation();
else if (P2D.Transition(i).Before() == TopAbs_OUT) {
OO = TopAbs_FORWARD;
}
V.Orientation(OO);
if (i == 1) LV1.Append(V);
else LV2.Append(V);
}
}
}
} // if (intersect)
//----------------------------------
// Test the extremities of the edges.
//----------------------------------
// add to LV* vertices for vertex-vertex closeness
Standard_Real U1,U2;
Standard_Real TolConf2, TolConf;
TopoDS_Vertex V1[2],V2[2];
TopExp::Vertices(E1,V1[0],V1[1]);
TopExp::Vertices(E2,V2[0],V2[1]);
Standard_Integer i,j,k;
for (j = 0; j < 2; j++) {
if (V1[j].IsNull()) continue;
for ( k = 0; k < 2; k++) {
if (V2[k].IsNull()) continue;
gp_Pnt P1 = BRep_Tool::Pnt(V1[j]);
gp_Pnt P2 = BRep_Tool::Pnt(V2[k]);
TolConf = BRep_Tool::Tolerance(V1[j]) + BRep_Tool::Tolerance(V2[k]);
TolConf = Max (Tol, TolConf);
TolConf2 = TolConf * TolConf;
if (!intersect)
TolConf2 *= 100;
Standard_Real SqDist = P1.SquareDistance(P2);
if (SqDist <= TolConf2) {
TopoDS_Vertex V = BRepLib_MakeVertex(P1);
V.Orientation(TopAbs_INTERNAL);
U1 = (j == 0) ? f[1] : l[1];
U2 = (k == 0) ? f[2] : l[2];
B.UpdateVertex(V,U1,E1,TolConf);
B.UpdateVertex(V,U2,E2,TolConf);
LV1.Prepend(V.Oriented(V1[j].Orientation()));
LV2.Prepend(V.Oriented(V2[k].Orientation()));
}
}
}
Standard_Boolean AffichPurge = Standard_False;
if ( LV1.IsEmpty()) return;
//----------------------------------
// Purge of all the vertices.
//----------------------------------
// remove one of close vertices
TopTools_ListIteratorOfListOfShape it1LV1,it1LV2,it2LV1;
gp_Pnt P1,P2;
Standard_Boolean Purge = Standard_True;
while (Purge) {
i = 1;
Purge = Standard_False;
for (it1LV1.Initialize(LV1),it1LV2.Initialize(LV2);
it1LV1.More(); it1LV1.Next(),it1LV2.Next()) {
j = 1;
it2LV1.Initialize(LV1);
while (j < i) {
const TopoDS_Vertex& VE1 = TopoDS::Vertex(it1LV1.Value());
const TopoDS_Vertex& VE2 = TopoDS::Vertex(it2LV1.Value());
Standard_Real Tol1 = BRep_Tool::Tolerance( VE1 );
Standard_Real Tol2 = BRep_Tool::Tolerance( VE2 );
P1 = BRep_Tool::Pnt( VE1 );
P2 = BRep_Tool::Pnt( VE2 );
if (P1.IsEqual(P2, Tol1 + Tol2)) {
LV1.Remove(it1LV1);
LV2.Remove(it1LV2);
if (AffichPurge) {
MESSAGE ("Vertices confused purged in EdgeInter.")
}
Purge = Standard_True;
break;
}
j++;
it2LV1.Next();
}
if (Purge) break;
i++;
}
}
// care of new closed edges, they always intersect with seam at end
if (V1[0].IsSame( V1[1] ) && NewEdges.Contains(E1) )
treatClosed (E1,f[1],l[1],LV1,LV2);
if (V2[0].IsSame( V2[1] ) && NewEdges.Contains(E2) )
treatClosed (E2,f[2],l[2],LV2,LV1);
//---------------------------------
// Stocking vertex .
//---------------------------------
//StorePart2d (E1,E2,LV1,LV2,AsDes,Tol);
for ( it1LV1.Initialize( LV1 ); it1LV1.More(); it1LV1.Next())
Partition_Inter2d::AddVonE ( TopoDS::Vertex( it1LV1.Value()), E1,E2,AsDes);
}
//=======================================================================
//function : CompletPart2d
//purpose : Computes the intersections between the edges stored
// is AsDes as descendants of <F> . Intersections is computed
// between two edges if one of them is bound in NewEdges.
//=======================================================================
void Partition_Inter2d::CompletPart2d (const Handle(BRepAlgo_AsDes)& AsDes,
const TopoDS_Face& F,
const TopTools_MapOfShape& NewEdges)
{
#ifdef DEB
NbF2d++;
NbE2d = 0;
#endif
//Do not intersect the edges of a face
TopTools_IndexedMapOfShape EdgesOfFace;
TopExp::MapShapes( F, TopAbs_EDGE , EdgesOfFace);
//-------------------------------------------------------------------
// compute the intersection2D on the faces touched by the intersection3D
//-------------------------------------------------------------------
TopTools_ListIteratorOfListOfShape it1LE ;
TopTools_ListIteratorOfListOfShape it2LE ;
//-----------------------------------------------
// Intersection edge-edge.
//-----------------------------------------------
const TopTools_ListOfShape& LE = AsDes->Descendant(F);
TopoDS_Vertex V1,V2;
Standard_Integer j, i = 1;
TopoDS_Face FF = F;
FF.Orientation(TopAbs_FORWARD);
for ( it1LE.Initialize(LE) ; it1LE.More(); it1LE.Next()) {
const TopoDS_Edge& E1 = TopoDS::Edge(it1LE.Value());
j = 1;
it2LE.Initialize(LE);
while (j < i && it2LE.More()) {
const TopoDS_Edge& E2 = TopoDS::Edge(it2LE.Value());
//----------------------------------------------------------
// Intersections of the new edges obtained by intersection
// between them and with the restrictions edges
//----------------------------------------------------------
if ( (!EdgesOfFace.Contains(E1) || !EdgesOfFace.Contains(E2)) &&
(NewEdges.Contains(E1) || NewEdges.Contains(E2)) ) {
EdgesPartition(FF,E1,E2,AsDes,NewEdges,Standard_True);
}
it2LE.Next();
j++;
}
i++;
}
}

View File

@ -1,110 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Inter2d.hxx
// Module : GEOM
#ifndef _Partition_Inter2d_HeaderFile
#define _Partition_Inter2d_HeaderFile
#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
#include <Handle_BRepAlgo_AsDes.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
class BRepAlgo_AsDes;
class TopoDS_Face;
class TopTools_MapOfShape;
class TopoDS_Vertex;
class TopTools_ListOfShape;
class TopoDS_Edge;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class Partition_Inter2d {
public:
void* operator new(size_t,void* anAddress)
{
return anAddress;
}
void* operator new(size_t size)
{
return Standard::Allocate(size);
}
void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// Methods PUBLIC
//
Standard_EXPORT static void CompletPart2d(const Handle(BRepAlgo_AsDes)& AsDes,const TopoDS_Face& F,const TopTools_MapOfShape& NewEdges) ;
Standard_EXPORT static TopoDS_Vertex FindEndVertex(const TopTools_ListOfShape& VertList,const Standard_Real f,const Standard_Real l,const TopoDS_Edge& E,Standard_Boolean& First,Standard_Real& DU) ;
Standard_EXPORT static TopoDS_Vertex AddVonE(const TopoDS_Vertex& V,const TopoDS_Edge& E1,const TopoDS_Edge& E2,const Handle(BRepAlgo_AsDes)& AsDes) ;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
};
// other Inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -1,31 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Inter2d.ixx
// Module : GEOM
#include "Partition_Inter2d.jxx"

View File

@ -1,47 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Inter2d.jxx
// Module : GEOM
#ifndef _BRepAlgo_AsDes_HeaderFile
#include <BRepAlgo_AsDes.hxx>
#endif
#ifndef _TopoDS_Face_HeaderFile
#include <TopoDS_Face.hxx>
#endif
#ifndef _TopTools_MapOfShape_HeaderFile
#include <TopTools_MapOfShape.hxx>
#endif
#ifndef _TopoDS_Vertex_HeaderFile
#include <TopoDS_Vertex.hxx>
#endif
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _TopoDS_Edge_HeaderFile
#include <TopoDS_Edge.hxx>
#endif
#ifndef _Partition_Inter2d_HeaderFile
#include "Partition_Inter2d.hxx"
#endif

View File

@ -1,168 +0,0 @@
-- GEOM PARTITION : partition algorithm
--
-- Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
--
--
--
-- File : Partition_Inter3d.cdl
-- Author : Benedicte MARTIN
-- Module : GEOM
class Inter3d from Partition
---Purpose: Computes the intersection face face in a set of faces
-- Store the result in a SD as AsDes.
uses
Edge from TopoDS,
Vertex from TopoDS,
DataMapOfShapeShape from TopTools,
MapOfShape from TopTools,
Boolean from Standard,
AsDes from BRepAlgo,
Image from BRepAlgo,
Shape from TopoDS,
Face from TopoDS,
ListOfShape from TopTools,
Real from Standard,
State from TopAbs,
DataMapOfShapeListOfShape from TopTools
is
Create returns Inter3d from Partition;
Create(AsDes : mutable AsDes from BRepAlgo);
CompletPart3d (me : in out; SetOfFaces1 : ListOfShape from TopTools;
FaceShapeMap: DataMapOfShapeShape from TopTools)
is static;
FacesPartition (me : in out; F1, F2 : Face from TopoDS)
is static;
----------------------------
---Category: Result Querying
----------------------------
IsDone(me ; F1,F2 : Face from TopoDS)
returns Boolean from Standard is static;
---Purpose: return True if F1-F2 pair has been processed
TouchedFaces(me : in out) returns MapOfShape from TopTools
---C++: return &
is static;
---Purpose: return map of
AsDes(me) returns AsDes from BRepAlgo
is static;
NewEdges(me : in out) returns MapOfShape from TopTools
---C++: return &
is static;
-------------------------------
---Category: Same domain shapes
-------------------------------
HasSameDomainF(me; F : Shape from TopoDS)
returns Boolean from Standard;
---Purpose: Return true if F has same domain faces
IsSameDomainF(me; F1, F2 : Shape from TopoDS)
returns Boolean from Standard;
---Purpose: Return true if F1 and F2 are same domain faces
SameDomain(me; F : Face from TopoDS)
returns ListOfShape from TopTools;
---C++: return const &
---Purpose: Return same domain faces of F
ReplaceSameDomainV (me; V : Vertex from TopoDS;
E : Edge from TopoDS)
returns Vertex from TopoDS;
---Purpose: return same domain vertex of V if it was replaced
-- and make this vertex to be on E too, else return V
--------------------------
---Category: Section edges
--------------------------
SectionEdgesAD (me) returns AsDes from BRepAlgo
is static;
IsSectionEdge (me; E : Edge from TopoDS)
returns Boolean from Standard;
---Purpose: return True if E is an edge of an initial face and
-- E intersects aother face
HasSectionEdge (me; F : Face from TopoDS)
returns Boolean from Standard;
---Purpose: return True if F is intersected by an edge of
-- other face
IsSplitOn (me; NewE, OldE : Edge from TopoDS;
F : Face from TopoDS)
returns Boolean from Standard;
---Purpose: return True if NewE is split of OldE on F;
-- no check if NewE is split of OldE :)
SectionEdgeFaces (me; SecE : Edge from TopoDS)
returns ListOfShape from TopTools;
---C++: return const&
---Purpose: return faces cut by section edge
--------------------
---Category: Private
--------------------
Inter3D (me: in out; F1, F2 : Face from TopoDS;
LInt : in out ListOfShape from TopTools)
is static private;
StorePart3d(me : in out; F1,F2 : Face from TopoDS;
LInt1 : ListOfShape from TopTools)
is static private;
SetDone(me : in out; F1,F2 : Face from TopoDS)
is static private;
Affiche (me; SetOfFaces : ListOfShape from TopTools)
is static private;
fields
myAsDes : AsDes from BRepAlgo;
myDone : DataMapOfShapeListOfShape from TopTools;
myTouched : MapOfShape from TopTools;
myNewEdges : MapOfShape from TopTools;
-- section edges: existing edges that are intersection lines,
-- may be partially.
-- Store as
-- FACE -> SECTION EDGES, SECTION EDGE -> OTHER SECTION EDGE
mySectionEdgesAD : AsDes from BRepAlgo;
-- same domain shapes
-- faces
mySameDomainFM : DataMapOfShapeListOfShape from TopTools;
-- vertex -> vertex replacement
mySameDomainVM : DataMapOfShapeShape from TopTools;
end Inter3d;

View File

@ -1,861 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Inter3d.cxx
// Author : Benedicte MARTIN
// Module : GEOM
// $Header$
using namespace std;
#include "Partition_Inter3d.ixx"
#include "Partition_Inter2d.hxx"
#include "utilities.h"
#include <BRepOffset_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepAlgo_AsDes.hxx>
#include <BRepAlgo_Image.hxx>
#include <BRepLib.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Compound.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopOpeBRepTool_BoxSort.hxx>
#ifdef DEB
#include <DBRep.hxx>
#endif
#include <stdio.h>
#include <TopOpeBRepDS_HDataStructure.hxx>
#include <TopOpeBRep_DSFiller.hxx>
#include <TopOpeBRepTool_GeomTool.hxx>
#include <TopOpeBRepTool_OutCurveType.hxx>
#include <TopOpeBRepDS_BuildTool.hxx>
#include <TopOpeBRepBuild_Builder.hxx>
#include <TopOpeBRepDS_CurveExplorer.hxx>
#include <Geom2d_Curve.hxx>
#include <TopOpeBRepDS_PointIterator.hxx>
#include <TopOpeBRepDS_Transition.hxx>
#include <Geom_Curve.hxx>
#include <TopOpeBRepTool_CurveTool.hxx>
#include <TopOpeBRepDS_Interference.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
#include <BRepLib_MakeVertex.hxx>
#include <Precision.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <BRepTools.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_Surface.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
//=======================================================================
//function : Partition_Inter3d
//purpose :
//=======================================================================
Partition_Inter3d::Partition_Inter3d()
{
}
//=======================================================================
//function : Partition_Inter3d
//purpose :
//=======================================================================
Partition_Inter3d::Partition_Inter3d(const Handle(BRepAlgo_AsDes)& AsDes)
:myAsDes(AsDes)
{
mySectionEdgesAD = new BRepAlgo_AsDes;
}
//=======================================================================
//function : CompletPart3d
//purpose : FaceShapeMap is just to know the shape a face belongs to
//=======================================================================
void Partition_Inter3d::CompletPart3d(const TopTools_ListOfShape& SetOfFaces1,
const TopTools_DataMapOfShapeShape& FaceShapeMap)
{
if (myAsDes.IsNull())
myAsDes = new BRepAlgo_AsDes;
TopTools_ListIteratorOfListOfShape it;
//---------------------------------------------------------------
// Construction of bounding boxes.
//---------------------------------------------------------------
BRep_Builder B;
TopoDS_Compound CompOS;
B.MakeCompound(CompOS);
for (it.Initialize(SetOfFaces1); it.More(); it.Next())
B.Add(CompOS, it.Value());
TopOpeBRepTool_BoxSort BOS;
BOS.AddBoxesMakeCOB(CompOS,TopAbs_FACE);
for (it.Initialize(SetOfFaces1); it.More(); it.Next()) {
TopoDS_Face F1 = TopoDS::Face(it.Value());
// avoid intersecting faces of one shape
TopoDS_Shape S1;
if (FaceShapeMap.IsBound(F1)) S1 = FaceShapeMap.Find(F1);
// avoid intersecting faces sharing vertices, suppose they belong to
// shapes sharing same faces
TopTools_IndexedMapOfShape VM;
TopExp::MapShapes( F1, TopAbs_VERTEX, VM);
TColStd_ListIteratorOfListOfInteger itLI = BOS.Compare(F1);
for (; itLI.More(); itLI.Next()) {
TopoDS_Face F2 = TopoDS::Face(BOS.TouchedShape(itLI));
if (F1.IsSame(F2) || IsDone(F1,F2))
continue;
TopoDS_Shape S2;
if (FaceShapeMap.IsBound(F2)) S2 = FaceShapeMap.Find(F2);
if (!S1.IsNull() && S1.IsSame(S2))
continue; // descendants of one shape
TopExp_Explorer expV (F2, TopAbs_VERTEX);
for ( ; expV.More(); expV.Next())
if (VM.Contains( expV.Current() ))
break;
if (expV.More())
continue; // faces have a common edge
F1.Orientation(TopAbs_FORWARD);
F2.Orientation(TopAbs_FORWARD);
FacesPartition(F1,F2);
}
// mark as modified a face which has at least one new edge
if (!myAsDes->HasDescendant( F1 ))
continue;
TopTools_ListIteratorOfListOfShape itE (myAsDes->Descendant( F1 ));
for ( ; itE.More(); itE.Next()) {
if (myNewEdges.Contains( itE.Value())) {
myTouched.Add( F1 );
break;
}
}
}
}
//=======================================================================
//function : PutInBounds
//purpose :
//=======================================================================
static void PutInBounds (const TopoDS_Face& F,
const TopoDS_Edge& E,
Handle(Geom2d_Curve)& C2d)
{
Standard_Real umin,umax,vmin,vmax;
Standard_Real f,l;
BRep_Tool::Range(E,f,l);
TopLoc_Location L; // Recup S avec la location pour eviter la copie.
Handle (Geom_Surface) S = BRep_Tool::Surface(F,L);
if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
S = (*(Handle_Geom_RectangularTrimmedSurface*)&S)->BasisSurface();
}
//---------------
// Recadre en U.
//---------------
if (!S->IsUPeriodic() && !S->IsVPeriodic()) return;
BRepTools::UVBounds(F,umin,umax,vmin,vmax);
if (S->IsUPeriodic()) {
Standard_Real period = S->UPeriod();
Standard_Real eps = period*1.e-6;
gp_Pnt2d Pf = C2d->Value(f);
gp_Pnt2d Pl = C2d->Value(l);
gp_Pnt2d Pm = C2d->Value(0.34*f + 0.66*l);
Standard_Real minC = Min(Pf.X(),Pl.X()); minC = Min(minC,Pm.X());
Standard_Real maxC = Max(Pf.X(),Pl.X()); maxC = Max(maxC,Pm.X());
Standard_Real du = 0.;
if (minC< umin - eps) {
du = (int((umin - minC)/period) + 1)*period;
}
if (minC > umax + eps) {
du = -(int((minC - umax)/period) + 1)*period;
}
if (du != 0) {
gp_Vec2d T1(du,0.);
C2d->Translate(T1);
minC += du; maxC += du;
}
// Ajuste au mieux la courbe dans le domaine.
if (maxC > umax +100*eps) {
Standard_Real d1 = maxC - umax;
Standard_Real d2 = umin - minC + period;
if (d2 < d1) du =-period;
if ( du != 0.) {
gp_Vec2d T2(du,0.);
C2d->Translate(T2);
}
}
}
//------------------
// Recadre en V.
//------------------
if (S->IsVPeriodic()) {
Standard_Real period = S->VPeriod();
Standard_Real eps = period*1.e-6;
gp_Pnt2d Pf = C2d->Value(f);
gp_Pnt2d Pl = C2d->Value(l);
gp_Pnt2d Pm = C2d->Value(0.34*f + 0.66*l);
Standard_Real minC = Min(Pf.Y(),Pl.Y()); minC = Min(minC,Pm.Y());
Standard_Real maxC = Max(Pf.Y(),Pl.Y()); maxC = Max(maxC,Pm.Y());
Standard_Real dv = 0.;
if (minC< vmin - eps) {
dv = (int((vmin - minC)/period) + 1)*period;
}
if (minC > vmax + eps) {
dv = -(int((minC - vmax)/period) + 1)*period;
}
if (dv != 0) {
gp_Vec2d T1(0.,dv);
C2d->Translate(T1);
minC += dv; maxC += dv;
}
// Ajuste au mieux la courbe dans le domaine.
if (maxC > vmax +100*eps) {
Standard_Real d1 = maxC - vmax;
Standard_Real d2 = vmin - minC + period;
if (d2 < d1) dv =-period;
if ( dv != 0.) {
gp_Vec2d T2(0.,dv);
C2d->Translate(T2);
}
}
}
}
//=======================================================================
//function : Inter3D
//purpose :
//=======================================================================
void Partition_Inter3d::Inter3D(const TopoDS_Face& F1,
const TopoDS_Face& F2,
TopTools_ListOfShape& L)
{
BRep_Builder B;
// fill the data Structure
Handle(TopOpeBRepDS_HDataStructure) DatStr = new TopOpeBRepDS_HDataStructure();
TopOpeBRep_DSFiller DSFiller;
DSFiller.Insert(F1,F2,DatStr);
// define the GeomTool used by the DSFiller :
// compute BSpline of degree 1 on intersection curves.
Standard_Real tol3dAPPROX = 1e-7;
Standard_Real tol2dAPPROX = 1e-7;
TopOpeBRepTool_GeomTool GT2 (TopOpeBRepTool_APPROX);
GT2.SetTolerances(tol3dAPPROX,tol2dAPPROX);
TopOpeBRepDS_BuildTool BT(GT2);
// Perform Section
TopOpeBRepBuild_Builder TopB(BT);
TopB.Perform(DatStr);
// ===============
// Store new edges
// ===============
L.Clear();
TopOpeBRepDS_CurveExplorer cex(DatStr->DS());
for (; cex.More(); cex.Next()) {
const TopOpeBRepDS_Curve& CDS = cex.Curve();
Standard_Integer ic = cex.Index();
Handle(Geom2d_Curve) pc1 = CDS.Curve1();
Handle(Geom2d_Curve) pc2 = CDS.Curve2();
TopTools_ListIteratorOfListOfShape itLE = TopB.NewEdges(ic);
while (itLE.More()) {
TopoDS_Edge E = TopoDS::Edge(itLE.Value());
// Standard_Real f,l;
// BRep_Tool::Range(E,f,l);
PutInBounds (F1,E,pc1);
PutInBounds (F2,E,pc2);
B.UpdateEdge (E,pc1,F1,0.);
B.UpdateEdge (E,pc2,F2,0.);
L.Append (E);
itLE.Next();
if (itLE.More()) {
pc1 = Handle(Geom2d_Curve)::DownCast(pc1->Copy());
pc2 = Handle(Geom2d_Curve)::DownCast(pc2->Copy());
}
}
}
// ===================================================
// Store section edges, same domain faces and verives
// ===================================================
TopTools_ListOfShape empty, LSP, LSE;
if ( DatStr->HasSameDomain( F1 )) { // same domain faces
if (!mySameDomainFM.IsBound(F1))
mySameDomainFM.Bind(F1,empty);
if (!mySameDomainFM.IsBound(F2))
mySameDomainFM.Bind(F2,empty);
mySameDomainFM(F1).Append(F2);
mySameDomainFM(F2).Append(F1);
}
const TopOpeBRepDS_DataStructure& DS = DatStr->DS();
Standard_Integer j,i,nes = DS.NbSectionEdges();
if (!nes) return;
TopoDS_Vertex V, sdeV1, sdeV2;
TopTools_MapOfShape MV;
// put vertices on section edges
for (i=1;i<=nes;i++) {
TopoDS_Edge se, sde, oe; // section, same domain, other edge
se = DS.SectionEdge(i);
if (! TopB.IsSplit(se,TopAbs_ON))
continue;
if (DatStr->HasSameDomain(se)) {
sde = TopoDS::Edge( DatStr->SameDomain(se).Value() );
TopExp::Vertices( sde, sdeV1, sdeV2);
}
TColStd_MapOfInteger MIV;
TopOpeBRepDS_PointIterator itP (DS.ShapeInterferences( se ));
itP.SupportKind( TopOpeBRepDS_EDGE );
for (; itP.More(); itP.Next()) {
oe = TopoDS::Edge( DS.Shape( itP.Support()));
if (itP.IsVertex()) {
if ( !MIV.Add( itP.Current() ))
continue;
V = TopoDS::Vertex( DS.Shape( itP.Current()));
if ( !sde.IsNull() && (V.IsSame(sdeV1) || V.IsSame(sdeV2)) )
oe = sde;
V = ReplaceSameDomainV( V , oe );
V.Orientation( TopAbs_INTERNAL);
B.UpdateVertex( V, itP.Parameter(), se, 0.);
}
else {
const TopOpeBRepDS_Point& DSP = DS.Point( itP.Current());
V = BRepLib_MakeVertex( DSP.Point() );
V.Orientation( TopAbs_INTERNAL);
B.UpdateVertex( V, itP.Parameter(), se, DSP.Tolerance());
// make V be on the other edge
TopOpeBRepDS_PointIterator itOP (DS.ShapeInterferences( oe ));
for (; itOP.More(); itOP.Next()) {
const TopOpeBRepDS_Point& ODSP = DS.Point( itOP.Current());
if ( DSP.IsEqual (ODSP)) {
B.UpdateVertex( V, itOP.Parameter(), TopoDS::Edge(oe), ODSP.Tolerance());
break;
}
}
}
TopoDS_Vertex addedV = Partition_Inter2d::AddVonE( V,se,oe,myAsDes);
if (!addedV.IsSame( V ))
mySameDomainVM.Bind (V, addedV);
MV.Add( addedV );
}
}
TopB.SplitSectionEdges();
TopTools_DataMapOfShapeShape SEM; // map split - section edge
TopTools_IndexedMapOfShape ME[2];
TopExp::MapShapes( F1, TopAbs_EDGE, ME[1]);
TopExp::MapShapes( F2, TopAbs_EDGE, ME[0]);
// add section edge to the face it intersects and find
// splits ON that do not have same domain pair
for (i=1;i<=nes;i++) {
const TopoDS_Edge& se = DS.SectionEdge(i);
if (! TopB.IsSplit(se,TopAbs_ON))
continue;
Standard_Integer ancRank = DS.AncestorRank(se);
if (ME[ancRank-1].Contains( se ))
continue; // se is an edge of face it intersects
const TopoDS_Face& F = (ancRank == 1) ? F2 : F1;
// add se to face but dont add twice
TopTools_ListIteratorOfListOfShape itE;
if (myAsDes->HasDescendant( F )) {
for (itE.Initialize( (myAsDes->Descendant( F )) ); itE.More(); itE.Next())
if (se.IsSame( itE.Value() ))
break;
}
if (!itE.More()) {
myAsDes->Add( F, se );
Standard_Real tol, f,l, umin=1e100, umax=-1e100;
Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( se, F, f,l);
if (pc.IsNull()) {
TopTools_ListIteratorOfListOfShape it( TopB.Splits(se,TopAbs_ON) );
for ( ;it.More();it.Next()) {
const TopoDS_Edge& E = TopoDS::Edge ( it.Value());
BRep_Tool::Range(E, f, l);
umin = Min( umin, f);
umax = Max( umax, l);
}
Handle(Geom_Curve) C3d = BRep_Tool::Curve( se, f, l);
if (umin < umax) // sometimes umin == umax for closed edge
C3d = new Geom_TrimmedCurve( C3d, umin, umax);
pc = TopOpeBRepTool_CurveTool::MakePCurveOnFace (F,C3d,tol);
if (pc.IsNull()) {
MESSAGE (" CANT BUILD PCURVE ");
}
B.UpdateEdge( se, pc, F, tol);
}
}
// to detect splits that do not have same domain pair
TopTools_ListIteratorOfListOfShape it( TopB.Splits(se,TopAbs_ON) );
for ( ;it.More();it.Next()) {
const TopoDS_Edge& S = TopoDS::Edge ( it.Value());
if (SEM.IsBound( S ))
SEM.UnBind( S );
else
SEM.Bind( S, se);
}
}
// store vertices of ON splits and bind section edges to faces
for (i=1;i<=nes;i++) {
const TopoDS_Edge& se = DS.SectionEdge(i);
if (! TopB.IsSplit(se,TopAbs_ON))
continue;
Standard_Integer ancRank = DS.AncestorRank(se);
if (ME[ancRank-1].Contains( se ))
continue; // se is an edge of face it intersects
TopoDS_Face F = (ancRank == 1) ? F2 : F1;
// add vertices of splits
Standard_Boolean added = Standard_False;
TopTools_ListIteratorOfListOfShape it( TopB.Splits(se,TopAbs_ON) );
for ( ;it.More();it.Next()) {
const TopoDS_Edge& S = TopoDS::Edge ( it.Value());
if (!SEM.IsBound( S ))
continue;
added = Standard_True;
mySectionEdgesAD->Add( F, se );
TopoDS_Vertex VS[2];
TopExp::Vertices (S, VS[0], VS[1]);
for (j=0; j<2; ++j) {
if (mySameDomainVM.IsBound( VS[j] ))
VS[j] = TopoDS::Vertex( mySameDomainVM( VS[j] ));
if ( !MV.Contains( VS[j] )) {
// find equal vertex on se - point interference
gp_Pnt P1 = BRep_Tool::Pnt( VS[j] );
TopTools_ListIteratorOfListOfShape itV( myAsDes->Descendant(se) );
for (; itV.More(); itV.Next()) {
V = TopoDS::Vertex( itV.Value() );
gp_Pnt P2 = BRep_Tool::Pnt( V );
if (P1.IsEqual( P2, Precision::Confusion())) {
mySameDomainVM.Bind (VS[j], V);
VS[j] = V;
break;
}
}
if (!itV.More()) // no interferences with edges
myAsDes->Add( se, VS[j]);
}
mySectionEdgesAD->Add( F, VS[j]);
}
mySectionEdgesAD->Add( F, S );
}
if (!added)
mySectionEdgesAD->Add( F, se );
myNewEdges.Add( se );
}
}
//=======================================================================
//function : FacesPartition
//purpose :
//=======================================================================
void Partition_Inter3d::FacesPartition(const TopoDS_Face& F1,
const TopoDS_Face& F2)
//(const TopTools_DataMapOfShapeListOfShape& /*SetOfFaces2*/)
{
TopTools_ListOfShape LInt;
Inter3D (F1,F2,LInt);
StorePart3d (F1,F2,LInt);
}
//=======================================================================
//function : SetDone
//purpose :
//=======================================================================
void Partition_Inter3d::SetDone(const TopoDS_Face& F1,
const TopoDS_Face& F2)
{
if (!myDone.IsBound(F1)) {
TopTools_ListOfShape empty;
myDone.Bind(F1,empty);
}
myDone(F1).Append(F2);
if (!myDone.IsBound(F2)) {
TopTools_ListOfShape empty;
myDone.Bind(F2,empty);
}
myDone(F2).Append(F1);
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean Partition_Inter3d::IsDone(const TopoDS_Face& F1,
const TopoDS_Face& F2)
const
{
if (myDone.IsBound(F1)) {
TopTools_ListIteratorOfListOfShape it (myDone(F1));
for (; it.More(); it.Next()) {
if (it.Value().IsSame(F2)) return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : StorePart3d
//purpose :
//=======================================================================
void Partition_Inter3d::StorePart3d(const TopoDS_Face& F1,
const TopoDS_Face& F2,
const TopTools_ListOfShape& LInt)
{
if (!LInt.IsEmpty()) {
myAsDes->Add( F1,LInt);
myAsDes->Add( F2,LInt);
TopTools_ListIteratorOfListOfShape it(LInt);
for (; it.More(); it.Next()) {
TopoDS_Edge E = TopoDS::Edge(it.Value());
BRep_Builder B;
B.SameParameter(E,Standard_False);
BRepLib::SameParameter(E,1.0e-7);
myNewEdges.Add(E);
}
}
SetDone(F1,F2);
}
//=======================================================================
//function : TouchedFaces
//purpose :
//=======================================================================
TopTools_MapOfShape& Partition_Inter3d::TouchedFaces()
{
return myTouched;
}
//=======================================================================
//function : AsDes
//purpose :
//=======================================================================
Handle(BRepAlgo_AsDes) Partition_Inter3d::AsDes() const
{
return myAsDes;
}
//=======================================================================
//function : NewEdges
//purpose :
//=======================================================================
TopTools_MapOfShape& Partition_Inter3d::NewEdges()
{
return myNewEdges;
}
//=======================================================================
//function : Affiche
//purpose :
//=======================================================================
void Partition_Inter3d::Affiche(const TopTools_ListOfShape& SetOfFaces) const
{
#ifdef DEB
char PSection[1024];
char *section=PSection;
Standard_Integer i = 0;
Standard_Real j=1;
TopTools_ListOfShape aList;
TopTools_ListIteratorOfListOfShape it;
for (it.Initialize(SetOfFaces); it.More(); it.Next()) {
const TopoDS_Shape& OS = it.Value();
aList=myAsDes->Descendant(OS);
MESSAGE ( " the number of items stored in the list " << j << " : " << aList.Extent() )
j++;
TopTools_ListIteratorOfListOfShape itaList;
for (itaList.Initialize(aList); itaList.More(); itaList.Next()) {
const TopoDS_Shape& SS = itaList.Value();
i++;
sprintf(PSection,"section_%d",i);
DBRep::Set(section,SS);
}
}
#endif
}
//=======================================================================
//function : SameDomain
//purpose :
//=======================================================================
const TopTools_ListOfShape& Partition_Inter3d::SameDomain(const TopoDS_Face& F) const
{
if (mySameDomainFM.IsBound( F ))
return mySameDomainFM (F);
static TopTools_ListOfShape empty;
return empty;
}
//=======================================================================
//function : HasSameDomainF
//purpose : Return true if F has same domain faces
//=======================================================================
Standard_Boolean Partition_Inter3d::HasSameDomainF(const TopoDS_Shape& F) const
{
return mySameDomainFM.IsBound( F );
}
//=======================================================================
//function : IsSameDomain
//purpose : Return true if F1 and F2 are same domain faces
//=======================================================================
Standard_Boolean Partition_Inter3d::IsSameDomainF(const TopoDS_Shape& F1,
const TopoDS_Shape& F2) const
{
if (mySameDomainFM.IsBound( F1 )) {
TopTools_ListIteratorOfListOfShape it (mySameDomainFM( F1 ));
for (; it.More(); it.Next())
if (F2.IsSame( it.Value()))
return Standard_True;
}
return F1.IsSame( F2 );
}
//=======================================================================
//function : ReplaceSameDomainV
//purpose : return same domain vertex of V if it was replaced
// and make this vertex to be on E too, else return V
//=======================================================================
TopoDS_Vertex Partition_Inter3d::ReplaceSameDomainV(const TopoDS_Vertex& V,
const TopoDS_Edge& E) const
{
TopoDS_Vertex SDV = V;
if (mySameDomainVM.IsBound( V )) {
TopoDS_Vertex V1,V2;
TopExp::Vertices(E,V1,V2);
Standard_Boolean isClosed = V1.IsSame( V2 ) && V.IsSame(V1);
SDV = TopoDS::Vertex( mySameDomainVM(V) );
Standard_Real tol = BRep_Tool::Tolerance( V );
BRep_Builder B;
SDV.Orientation( V.Orientation());
if (isClosed) {
Standard_Real f, l;
BRep_Tool::Range (E, f, l);
Standard_Boolean isFirst = IsEqual( BRep_Tool::Parameter(V,E), f );
B.UpdateVertex(SDV, (isFirst ? f : l), E, tol);
SDV.Reverse();
B.UpdateVertex(SDV, (isFirst ? l : f), E, tol);
}
else
B.UpdateVertex (SDV, BRep_Tool::Parameter(V,E), E, tol);
}
return SDV;
}
//=======================================================================
//function : SectionEdgesAD
//purpose :
//=======================================================================
Handle(BRepAlgo_AsDes) Partition_Inter3d::SectionEdgesAD() const
{
return mySectionEdgesAD;
}
//=======================================================================
//function : IsSectionEdge
//purpose : return True if E is an edge of a face and it
// intersects an other face
//=======================================================================
Standard_Boolean
Partition_Inter3d::IsSectionEdge(const TopoDS_Edge& E) const
{
return mySectionEdgesAD->HasAscendant(E);
}
//=======================================================================
//function : HasSectionEdge
//purpose : return True if an edge of F intersects an other
// face or F is intersected by edge of an other face
//=======================================================================
Standard_Boolean
Partition_Inter3d::HasSectionEdge(const TopoDS_Face& F) const
{
return mySectionEdgesAD->HasDescendant(F);
}
//=======================================================================
//function : IsSplitOn
//purpose : return True if NewE is split of OldE on F
//=======================================================================
Standard_Boolean
Partition_Inter3d::IsSplitOn(const TopoDS_Edge& NewE,
const TopoDS_Edge& OldE,
const TopoDS_Face& F) const
{
if (! mySectionEdgesAD->HasDescendant(F))
return Standard_False;
TopTools_ListIteratorOfListOfShape itE ( mySectionEdgesAD->Descendant(F) );
for ( ; itE.More(); itE.Next()) {
if ( itE.Value().ShapeType() != TopAbs_EDGE ||
! OldE.IsSame ( itE.Value() ))
continue;
// an edge encountered, its vertices and a split come next
itE.Next();
if (!itE.More()) break;
const TopoDS_Shape& V3 = itE.Value();
if (V3.ShapeType() != TopAbs_VERTEX) continue;
itE.Next();
if (!itE.More()) break;
const TopoDS_Shape& V4 = itE.Value();
if (V4.ShapeType() != TopAbs_VERTEX) continue;
TopoDS_Vertex V1, V2;
TopExp::Vertices( OldE, V1, V2);
if ( V1.IsSame(V2) &&
(V1.IsSame(V3) || V1.IsSame(V4)) ) {
// closed old edge; use the split for the test
itE.Next();
if (!itE.More()) break;
const TopoDS_Edge& split = TopoDS::Edge( itE.Value() );
// check distance at middle point of NewE
Standard_Real f1,l1, f2,l2;
Handle(Geom2d_Curve) PC1 = BRep_Tool::CurveOnSurface( split, F ,f1,l1);
if (!PC1.IsNull()) {
Handle(Geom2d_Curve) PC2 = BRep_Tool::CurveOnSurface(NewE, F ,f2,l2);
gp_Pnt2d P = PC2->Value( 0.5*(f2+l2) );
Geom2dAPI_ProjectPointOnCurve proj (P, PC1, f1, l1);
if (proj.NbPoints() &&
proj.LowerDistance() <= Precision::Confusion())
return Standard_True;
}
else {
Handle(Geom_Curve) C1 = BRep_Tool::Curve( split ,f1,l1);
Handle(Geom_Curve) C2 = BRep_Tool::Curve( NewE ,f2,l2);
gp_Pnt P = C2->Value( 0.5*(f2+l2) );
GeomAPI_ProjectPointOnCurve proj (P, C1, f1, l1);
if (proj.NbPoints() &&
proj.LowerDistance() <= Precision::Confusion())
return Standard_True;
}
}
else {
Standard_Real u3 = BRep_Tool::Parameter( TopoDS::Vertex(V3), OldE);
Standard_Real u4 = BRep_Tool::Parameter( TopoDS::Vertex(V4), OldE);
Standard_Real f,l, u;
BRep_Tool::Range( NewE, f,l);
u = 0.5*(f+l);
f = Min(u3,u4);
l = Max(u3,u4);
if (u <= l && u >= f)
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : SectionEdgeFaces
//purpose : return faces cut by section edge
//=======================================================================
const TopTools_ListOfShape&
Partition_Inter3d::SectionEdgeFaces(const TopoDS_Edge& SecE) const
{
return mySectionEdgesAD->Ascendant( SecE );
}

View File

@ -1,143 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Inter3d.hxx
// Module : GEOM
#ifndef _Partition_Inter3d_HeaderFile
#define _Partition_Inter3d_HeaderFile
#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
#include <Handle_BRepAlgo_AsDes.hxx>
#endif
#ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#endif
#ifndef _TopTools_MapOfShape_HeaderFile
#include <TopTools_MapOfShape.hxx>
#endif
#ifndef _TopTools_DataMapOfShapeShape_HeaderFile
#include <TopTools_DataMapOfShapeShape.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
class BRepAlgo_AsDes;
class TopTools_ListOfShape;
class TopTools_DataMapOfShapeShape;
class TopoDS_Face;
class TopTools_MapOfShape;
class TopoDS_Shape;
class TopoDS_Vertex;
class TopoDS_Edge;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class Partition_Inter3d {
public:
void* operator new(size_t,void* anAddress)
{
return anAddress;
}
void* operator new(size_t size)
{
return Standard::Allocate(size);
}
void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// Methods PUBLIC
//
Standard_EXPORT Partition_Inter3d();
Standard_EXPORT Partition_Inter3d(const Handle(BRepAlgo_AsDes)& AsDes);
Standard_EXPORT void CompletPart3d(const TopTools_ListOfShape& SetOfFaces1,const TopTools_DataMapOfShapeShape& FaceShapeMap) ;
Standard_EXPORT void FacesPartition(const TopoDS_Face& F1,const TopoDS_Face& F2) ;
Standard_EXPORT Standard_Boolean IsDone(const TopoDS_Face& F1,const TopoDS_Face& F2) const;
Standard_EXPORT TopTools_MapOfShape& TouchedFaces() ;
Standard_EXPORT Handle_BRepAlgo_AsDes AsDes() const;
Standard_EXPORT TopTools_MapOfShape& NewEdges() ;
Standard_EXPORT Standard_Boolean HasSameDomainF(const TopoDS_Shape& F) const;
Standard_EXPORT Standard_Boolean IsSameDomainF(const TopoDS_Shape& F1,const TopoDS_Shape& F2) const;
Standard_EXPORT const TopTools_ListOfShape& SameDomain(const TopoDS_Face& F) const;
Standard_EXPORT TopoDS_Vertex ReplaceSameDomainV(const TopoDS_Vertex& V,const TopoDS_Edge& E) const;
Standard_EXPORT Handle_BRepAlgo_AsDes SectionEdgesAD() const;
Standard_EXPORT Standard_Boolean IsSectionEdge(const TopoDS_Edge& E) const;
Standard_EXPORT Standard_Boolean HasSectionEdge(const TopoDS_Face& F) const;
Standard_EXPORT Standard_Boolean IsSplitOn(const TopoDS_Edge& NewE,const TopoDS_Edge& OldE,const TopoDS_Face& F) const;
Standard_EXPORT const TopTools_ListOfShape& SectionEdgeFaces(const TopoDS_Edge& SecE) const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
Standard_EXPORT void Inter3D(const TopoDS_Face& F1,const TopoDS_Face& F2,TopTools_ListOfShape& LInt) ;
Standard_EXPORT void StorePart3d(const TopoDS_Face& F1,const TopoDS_Face& F2,const TopTools_ListOfShape& LInt1) ;
Standard_EXPORT void SetDone(const TopoDS_Face& F1,const TopoDS_Face& F2) ;
Standard_EXPORT void Affiche(const TopTools_ListOfShape& SetOfFaces) const;
// Fields PRIVATE
//
Handle_BRepAlgo_AsDes myAsDes;
TopTools_DataMapOfShapeListOfShape myDone;
TopTools_MapOfShape myTouched;
TopTools_MapOfShape myNewEdges;
Handle_BRepAlgo_AsDes mySectionEdgesAD;
TopTools_DataMapOfShapeListOfShape mySameDomainFM;
TopTools_DataMapOfShapeShape mySameDomainVM;
};
// other Inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -1,31 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Inter3d.ixx
// Module : GEOM
#include "Partition_Inter3d.jxx"

View File

@ -1,53 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Inter3d.jxx
// Module : GEOM
#ifndef _BRepAlgo_AsDes_HeaderFile
#include <BRepAlgo_AsDes.hxx>
#endif
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _TopTools_DataMapOfShapeShape_HeaderFile
#include <TopTools_DataMapOfShapeShape.hxx>
#endif
#ifndef _TopoDS_Face_HeaderFile
#include <TopoDS_Face.hxx>
#endif
#ifndef _TopTools_MapOfShape_HeaderFile
#include <TopTools_MapOfShape.hxx>
#endif
#ifndef _TopoDS_Shape_HeaderFile
#include <TopoDS_Shape.hxx>
#endif
#ifndef _TopoDS_Vertex_HeaderFile
#include <TopoDS_Vertex.hxx>
#endif
#ifndef _TopoDS_Edge_HeaderFile
#include <TopoDS_Edge.hxx>
#endif
#ifndef _Partition_Inter3d_HeaderFile
#include "Partition_Inter3d.hxx"
#endif

View File

@ -1,87 +0,0 @@
-- GEOM PARTITION : partition algorithm
--
-- Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
--
--
--
-- File : Partition_Loop.cdl
-- Author : Benedicte MARTIN
-- Module : GEOM
class Loop from Partition
---Purpose: Builds the loops from a set of edges on a face.
uses
Face from TopoDS,
Edge from TopoDS,
ListOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools
is
Create;
Init (me : in out; F : Face from TopoDS)
---Purpose: Init with <F> the set of edges must have
-- pcurves on <F>.
is static;
AddEdge (me : in out; E : in out Edge from TopoDS;
LV : ListOfShape from TopTools)
---Purpose: Add E with <LV>. <E> will be copied and trim
-- by vertices in <LV>.
is static;
AddConstEdge (me : in out; E : Edge from TopoDS)
---Purpose: Add <E> as const edge, E can be in the result.
is static;
Perform(me : in out)
---Purpose: Make loops.
is static;
NewWires (me)
---Purpose: Returns the list of wires performed.
-- can be an empty list.
---C++: return const &
returns ListOfShape from TopTools;
WiresToFaces (me : in out)
---Purpose: Build faces from the wires result.
is static;
NewFaces (me)
---Purpose: Returns the list of faces.
---Warning: The method <WiresToFaces> as to be called before.
-- can be an empty list.
---C++: return const &
returns ListOfShape from TopTools;
fields
myFace : Face from TopoDS;
myConstEdges : ListOfShape from TopTools;
myNewWires : ListOfShape from TopTools;
myNewFaces : ListOfShape from TopTools;
end Loop;

View File

@ -1,467 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Loop.cxx
// Author : Benedicte MARTIN
// Module : GEOM
// $Header$
using namespace std;
#include <stdio.h>
#include "Partition_Loop.ixx"
#include "utilities.h"
#include <BRep_Builder.hxx>
#include <BRepAlgo_FaceRestrictor.hxx>
#include <BRep_Tool.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfOrientedShape.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Iterator.hxx>
#include <Precision.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_TEdge.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
static char* name = new char[100];
static int nbe = 0;
//=======================================================================
//function : Partition_Loop
//purpose :
//=======================================================================
Partition_Loop::Partition_Loop()
{
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void Partition_Loop::Init(const TopoDS_Face& F)
{
myConstEdges.Clear();
myNewWires .Clear();
myNewFaces .Clear();
myFace = F;
}
//=======================================================================
//function : AddConstEdge
//purpose :
//=======================================================================
void Partition_Loop::AddConstEdge (const TopoDS_Edge& E)
{
myConstEdges.Append(E);
}
//=======================================================================
//function : FindDelta
//purpose :
//=======================================================================
static Standard_Real FindDelta(TopTools_ListOfShape& LE,
const TopoDS_Face& F)
{
Standard_Real dist, f, l;
Standard_Real d = Precision::Infinite();
TopTools_ListIteratorOfListOfShape itl;
for ( itl.Initialize(LE); itl.More(); itl.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(E,F,f,l);
gp_Pnt2d p = C->Value(f);
gp_Pnt2d pp = C->Value(l);
Standard_Real d1 = p.Distance(pp);
if (d1<d) { d=d1;}
}
dist = d ;
return dist;
}
//=======================================================================
//function : SelectEdge
//purpose : Find the edge <NE> connected <CE> by the vertex <CV> in the list <LE>.
// <NE> Is erased of the list. If <CE> is too in the list <LE>
// with the same orientation, it's erased of the list
//=======================================================================
static Standard_Boolean SelectEdge(const TopoDS_Face& F,
const TopoDS_Edge& CE,
const TopoDS_Vertex& CV,
TopoDS_Edge& NE,
TopTools_ListOfShape& LE)
{
TopTools_ListIteratorOfListOfShape itl;
NE.Nullify();
for ( itl.Initialize(LE); itl.More(); itl.Next()) {
if (itl.Value().IsEqual(CE)) {
LE.Remove(itl);
break;
}
}
if (LE.Extent() > 1) {
//--------------------------------------------------------------
// Several possible edges.
// - Test the edges differents of CE
//--------------------------------------------------------------
Standard_Real cf, cl, f, l;
TopoDS_Face FForward = F;
Handle(Geom2d_Curve) Cc, C;
FForward.Orientation(TopAbs_FORWARD);
Cc = BRep_Tool::CurveOnSurface(CE,FForward,cf,cl);
Standard_Real dist,distmin = 100*BRep_Tool::Tolerance(CV);
Standard_Real uc,u;
if (CE.Orientation () == TopAbs_FORWARD) uc = cl;
else uc = cf;
gp_Pnt2d P2,PV = Cc->Value(uc);
Standard_Real delta = FindDelta(LE,FForward);
for ( itl.Initialize(LE); itl.More(); itl.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
if (!E.IsSame(CE)) {
C = BRep_Tool::CurveOnSurface(E,FForward,f,l);
if (E.Orientation () == TopAbs_FORWARD) u = f;
else u = l;
P2 = C->Value(u);
dist = PV.Distance(P2);
if (dist <= distmin){
distmin = dist;
}
}
}
Standard_Real anglemax = - PI;
TopoDS_Edge SelectedEdge;
for ( itl.Initialize(LE); itl.More(); itl.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
if (!E.IsSame(CE)) {
C = BRep_Tool::CurveOnSurface(E,FForward,f,l);
if (E.Orientation () == TopAbs_FORWARD) u = f;
else u = l;
P2 = C->Value(u);
dist = PV.Distance(P2);
if (dist <= distmin + (1./3)*delta){
gp_Pnt2d PC, P;
gp_Vec2d CTg1, CTg2, Tg1, Tg2;
Cc->D2(uc, PC, CTg1, CTg2);
C->D2(u, P, Tg1, Tg2);
Standard_Real angle;
if (CE.Orientation () == TopAbs_REVERSED && E.Orientation () == TopAbs_FORWARD) {
angle = CTg1.Angle(Tg1.Reversed());
}
else if (CE.Orientation () == TopAbs_FORWARD && E.Orientation () == TopAbs_REVERSED) {
angle = (CTg1.Reversed()).Angle(Tg1);
}
else if (CE.Orientation () == TopAbs_REVERSED && E.Orientation () == TopAbs_REVERSED) {
angle = CTg1.Angle(Tg1);
}
else if (CE.Orientation () == TopAbs_FORWARD && E.Orientation () == TopAbs_FORWARD) {
angle = (CTg1.Reversed()).Angle(Tg1.Reversed());
}
if (angle >= anglemax) {
anglemax = angle ;
SelectedEdge = E;
}
}
}
}
for ( itl.Initialize(LE); itl.More(); itl.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
if (E.IsEqual(SelectedEdge)) {
NE = TopoDS::Edge(E);
LE.Remove(itl);
break;
}
}
}
else if (LE.Extent() == 1) {
NE = TopoDS::Edge(LE.First());
LE.RemoveFirst();
}
else {
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : SamePnt2d
//purpose :
//=======================================================================
static Standard_Boolean SamePnt2d(TopoDS_Vertex V,
TopoDS_Edge& E1,
TopoDS_Edge& E2,
TopoDS_Face& F)
{
Standard_Real f1,f2,l1,l2;
gp_Pnt2d P1,P2;
TopoDS_Shape aLocalF = F.Oriented(TopAbs_FORWARD);
TopoDS_Face FF = TopoDS::Face(aLocalF);
Handle(Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E1,FF,f1,l1);
Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E2,FF,f2,l2);
if (E1.Orientation () == TopAbs_FORWARD) P1 = C1->Value(f1);
else P1 = C1->Value(l1);
if (E2.Orientation () == TopAbs_FORWARD) P2 = C2->Value(l2);
else P2 = C2->Value(f2);
Standard_Real Tol = 100*BRep_Tool::Tolerance(V);
Standard_Real Dist = P1.Distance(P2);
return Dist < Tol;
}
//=======================================================================
//function : PurgeNewEdges
//purpose :
//=======================================================================
static void PurgeNewEdges(TopTools_ListOfShape& ConstEdges,
const TopTools_MapOfOrientedShape& UsedEdges)
{
TopTools_ListIteratorOfListOfShape it(ConstEdges);
while ( it.More()) {
const TopoDS_Shape& NE = it.Value();
if (!UsedEdges.Contains(NE)) {
ConstEdges.Remove(it);
}
else {
it.Next();
}
}
}
//=======================================================================
//function : StoreInMVE
//purpose :
//=======================================================================
static void StoreInMVE (const TopoDS_Face& F,
TopoDS_Edge& E,
TopTools_DataMapOfShapeListOfShape& MVE )
{
TopoDS_Vertex V1, V2;
TopTools_ListOfShape Empty;
TopExp::Vertices(E,V1,V2);
if (!MVE.IsBound(V1)) {
MVE.Bind(V1,Empty);
}
MVE(V1).Append(E);
if (!MVE.IsBound(V2)) {
MVE.Bind(V2,Empty);
}
MVE(V2).Append(E);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void Partition_Loop::Perform()
{
TopTools_DataMapOfShapeListOfShape MVE;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit, Mapit1;
TopTools_ListIteratorOfListOfShape itl;
TopoDS_Vertex V1,V2;
//-----------------------------------
// Construction map vertex => edges
//-----------------------------------
for (itl.Initialize(myConstEdges); itl.More(); itl.Next()) {
TopoDS_Edge& E = TopoDS::Edge(itl.Value());
StoreInMVE(myFace,E,MVE);
}
//----------------------------------------------
// Construction of all the wires and of all the new faces.
//----------------------------------------------
TopTools_MapOfOrientedShape UsedEdges;
while (!MVE.IsEmpty()) {
TopoDS_Vertex VF,CV;
TopoDS_Edge CE,NE,EF;
TopoDS_Wire NW;
BRep_Builder B;
Standard_Boolean End= Standard_False;
B.MakeWire(NW);
//--------------------------------
// EF first edge.
//--------------------------------
Mapit.Initialize(MVE);
EF = CE = TopoDS::Edge(Mapit.Value().First());
TopExp::Vertices(CE,V1,V2);
//--------------------------------
// VF first vertex
//--------------------------------
if (CE.Orientation() == TopAbs_FORWARD) {
CV = VF = V1;
}
else {
CV = VF = V2;
}
if (!MVE.IsBound(CV)) continue;
for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) {
if (itl.Value().IsEqual(CE)) {
MVE(CV).Remove(itl);
break;
}
}
int i = 0;
while (!End) {
//-------------------------------
// Construction of a wire.
//-------------------------------
TopExp::Vertices(CE,V1,V2);
if (!CV.IsSame(V1)) CV = V1; else CV = V2;
B.Add (NW,CE);
UsedEdges.Add(CE);
//--------------
// stop test
//--------------
if (!MVE.IsBound(CV) || MVE(CV).IsEmpty() || CV.IsSame(VF) ) {
if (CV.IsSame(VF)) {
if (MVE(CV).Extent() == 1 ) MVE.UnBind(CV);
else {
for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) {
if (itl.Value().IsEqual(CE)) {
MVE(CV).Remove(itl);
break;
}
}
}
}
End=Standard_True;
}
//--------------
// select edge
//--------------
else {
Standard_Boolean find = SelectEdge(myFace,CE,CV,NE,MVE(CV));
if (find) {
CE=NE;
if (MVE(CV).IsEmpty()) MVE.UnBind(CV);
if (CE.IsNull() ) {
MESSAGE ( " CE is NULL !!! " )
End=Standard_True;
}
}
else {
MESSAGE ( " edge doesn't exist " )
End=Standard_True;
}
}
}
//-----------------------------
// Test if the wire is closed
//-----------------------------
if (VF.IsSame(CV) && SamePnt2d(VF,EF,CE,myFace)) {
}
else{
MESSAGE ( "wire not closed" )
}
myNewWires.Append (NW);
}
PurgeNewEdges(myConstEdges,UsedEdges);
}
//=======================================================================
//function : NewWires
//purpose :
//=======================================================================
const TopTools_ListOfShape& Partition_Loop::NewWires() const
{
return myNewWires;
}
//=======================================================================
//function : NewFaces
//purpose :
//=======================================================================
const TopTools_ListOfShape& Partition_Loop::NewFaces() const
{
return myNewFaces;
}
//=======================================================================
//function : WiresToFaces
//purpose :
//=======================================================================
void Partition_Loop::WiresToFaces()
{
if (!myNewWires.IsEmpty()) {
BRepAlgo_FaceRestrictor FR;
TopAbs_Orientation OriF = myFace.Orientation();
TopoDS_Shape aLocalS = myFace.Oriented(TopAbs_FORWARD);
FR.Init (TopoDS::Face(aLocalS),Standard_False);
TopTools_ListIteratorOfListOfShape it(myNewWires);
for (; it.More(); it.Next()) {
FR.Add(TopoDS::Wire(it.Value()));
}
FR.Perform();
if (FR.IsDone()) {
for (; FR.More(); FR.Next()) {
myNewFaces.Append(FR.Current().Oriented(OriF));
}
}
}
}

View File

@ -1,118 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Loop.hxx
// Module : GEOM
#ifndef _Partition_Loop_HeaderFile
#define _Partition_Loop_HeaderFile
#ifndef _TopoDS_Face_HeaderFile
#include <TopoDS_Face.hxx>
#endif
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#endif
class TopoDS_Face;
class TopoDS_Edge;
class TopTools_ListOfShape;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class Partition_Loop {
public:
inline void* operator new(size_t,void* anAddress)
{
return anAddress;
}
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
}
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// inline void operator delete(void *anAddress, size_t size)
// {
// if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
// }
// Methods PUBLIC
//
Standard_EXPORT Partition_Loop();
Standard_EXPORT void Init(const TopoDS_Face& F) ;
Standard_EXPORT void AddConstEdge(const TopoDS_Edge& E) ;
Standard_EXPORT void Perform() ;
Standard_EXPORT const TopTools_ListOfShape& NewWires() const;
Standard_EXPORT void WiresToFaces() ;
Standard_EXPORT const TopTools_ListOfShape& NewFaces() const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
TopoDS_Face myFace;
TopTools_ListOfShape myConstEdges;
TopTools_ListOfShape myNewWires;
TopTools_ListOfShape myNewFaces;
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -1,31 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Loop.ixx
// Module : GEOM
#include "Partition_Loop.jxx"

View File

@ -1,41 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Loop.jxx
// Module : GEOM
#ifndef _TopoDS_Face_HeaderFile
#include <TopoDS_Face.hxx>
#endif
#ifndef _TopoDS_Edge_HeaderFile
#include <TopoDS_Edge.hxx>
#endif
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _TopTools_DataMapOfShapeShape_HeaderFile
#include <TopTools_DataMapOfShapeShape.hxx>
#endif
#ifndef _Partition_Loop_HeaderFile
#include "Partition_Loop.hxx"
#endif

View File

@ -1,83 +0,0 @@
-- GEOM PARTITION : partition algorithm
--
-- Copyright (C) 2003 CEA/DEN, EDF R&D
--
--
--
-- File : Partition_Loop2d.cdl
-- Author : Benedicte MARTIN
-- Module : GEOM
class Loop2d from Partition
---Purpose: Builds the loops from a set of edges on a face.
-- It works in supposition that all constant edges
-- are split edges of an initialization face and all
-- section edges are new on the face
uses
Orientation from TopAbs,
Boolean from Standard,
Face from TopoDS,
Image from BRepAlgo,
Face from TopoDS,
Edge from TopoDS,
ListOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools,
MapOfShape from TopTools
is
Create;
Init (me : in out; F : Face from TopoDS)
---Purpose: Init with <F> the set of edges must have
-- pcurves on <F>.
is static;
AddConstEdge (me : in out; E : Edge from TopoDS)
---Purpose: Add <E> as unique edge in the result.
is static;
AddSectionEdge (me : in out; E : Edge from TopoDS)
---Purpose: Add <E> as double edge in the result.
is static;
Perform(me : in out)
---Purpose: Make loops.
is static;
NewWires (me)
---Purpose: Returns the list of wires performed.
-- can be an empty list.
---C++: return const &
returns ListOfShape from TopTools;
WiresToFaces (me : in out; EdgeImage : Image from BRepAlgo)
---Purpose: Build faces from the wires result.
-- <EdgeImage> serves to find original edge by new
-- one.
is static;
NewFaces (me)
---Purpose: Returns the list of faces.
---Warning: The method <WiresToFaces> as to be called before.
-- can be an empty list.
---C++: return const &
returns ListOfShape from TopTools;
fields
myFace : Face from TopoDS;
myFaceOri : Orientation from TopAbs;
myConstEdges : ListOfShape from TopTools;
myNewWires : ListOfShape from TopTools;
myNewFaces : ListOfShape from TopTools;
-- internal wires do not contain constant edges
myInternalWL : ListOfShape from TopTools;
mySectionEdges : MapOfShape from TopTools;
end Loop2d;

File diff suppressed because it is too large Load Diff

View File

@ -1,106 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
//
//
// File : Partition_Loop2d.hxx
// Module : GEOM
#ifndef _Partition_Loop2d_HeaderFile
#define _Partition_Loop2d_HeaderFile
#ifndef _TopoDS_Face_HeaderFile
#include <TopoDS_Face.hxx>
#endif
#ifndef _TopAbs_Orientation_HeaderFile
#include <TopAbs_Orientation.hxx>
#endif
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _TopTools_MapOfShape_HeaderFile
#include <TopTools_MapOfShape.hxx>
#endif
class TopoDS_Face;
class TopoDS_Edge;
class TopTools_ListOfShape;
class BRepAlgo_Image;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class Partition_Loop2d {
public:
void* operator new(size_t,void* anAddress)
{
return anAddress;
}
void* operator new(size_t size)
{
return Standard::Allocate(size);
}
void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// Methods PUBLIC
//
Standard_EXPORT Partition_Loop2d();
Standard_EXPORT void Init(const TopoDS_Face& F) ;
Standard_EXPORT void AddConstEdge(const TopoDS_Edge& E) ;
Standard_EXPORT void AddSectionEdge(const TopoDS_Edge& E) ;
Standard_EXPORT void Perform() ;
Standard_EXPORT const TopTools_ListOfShape& NewWires() const;
Standard_EXPORT void WiresToFaces(const BRepAlgo_Image& EdgeImage) ;
Standard_EXPORT const TopTools_ListOfShape& NewFaces() const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
TopoDS_Face myFace;
TopAbs_Orientation myFaceOri;
TopTools_ListOfShape myConstEdges;
TopTools_ListOfShape myNewWires;
TopTools_ListOfShape myNewFaces;
TopTools_ListOfShape myInternalWL;
TopTools_MapOfShape mySectionEdges;
};
// other Inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -1,14 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
//
//
// File : Partition_Loop2d.ixx
// Module : GEOM
#include "Partition_Loop2d.jxx"

View File

@ -1,24 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
//
//
// File : Partition_Loop2d.jxx
// Module : GEOM
#ifndef _TopoDS_Face_HeaderFile
#include <TopoDS_Face.hxx>
#endif
#ifndef _TopoDS_Edge_HeaderFile
#include <TopoDS_Edge.hxx>
#endif
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _BRepAlgo_Image_HeaderFile
#include <BRepAlgo_Image.hxx>
#endif
#ifndef _Partition_Loop2d_HeaderFile
#include "Partition_Loop2d.hxx"
#endif

View File

@ -1,69 +0,0 @@
-- GEOM PARTITION : partition algorithm
--
-- Copyright (C) 2003 CEA/DEN, EDF R&D
--
--
--
-- File : Partition_Loop3d.cdl
-- Module : GEOM
class Loop3d from Partition
---Purpose: Builds the shells from a set of faces.
-- Provides methods for comparing faces mutual
-- location.
uses
Vec from gp,
MapOfOrientedShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools,
Face from TopoDS,
Edge from TopoDS,
ListOfShape from TopTools,
Shape from TopoDS
is
Create;
AddConstFaces (me : in out; S : Shape from TopoDS)
---Purpose: Add faces of <S> as unique faces in the result.
is static;
AddSectionFaces (me : in out; S : Shape from TopoDS)
---Purpose: Add faces of <S> as double faces in the result.
is static;
MakeShells (me : in out; AvoidFacesMap : MapOfOrientedShape from TopTools)
returns ListOfShape from TopTools is static;
---Purpose: Make and return shells.
-- <AvoidFacesMap> can contain faces that must not be
-- added to result shells.
---C++: return const &
---Category: class methods
IsInside (myclass; E : Edge from TopoDS;
F1, F2 : Face from TopoDS;
CountDot : Boolean from Standard;
Dot : in out Real from Standard;
GoodOri : in out Boolean from Standard)
returns Boolean from Standard;
---Purpose: check if <F2> is inside <F1> by edge <E>.
-- if <CountDot>, compute <Dot>: scalar production of
-- normalized vectors pointing inside faces, and
-- check if faces are oriented well for sewing
Normal (myclass; E : Edge from TopoDS;
F : Face from TopoDS) returns Vec from gp;
fields
myNewShells : ListOfShape from TopTools; -- result
myFaces : ListOfShape from TopTools;
myEFMap : IndexedDataMapOfShapeListOfShape from TopTools;
end Loop3d;

View File

@ -1,351 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
//
//
// File : Partition_Loop3d.cxx
// Module : GEOM
using namespace std;
#include "Partition_Loop3d.ixx"
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <BRep_Builder.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <Geom2d_Curve.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
#include <gp_Dir2d.hxx>
#include <Geom_Curve.hxx>
//=======================================================================
//function : Partition_Loop3d
//purpose :
//=======================================================================
Partition_Loop3d::Partition_Loop3d()
{
}
//=======================================================================
//function : AddConstFaces
//purpose : Add faces of <S> as unique faces in the result.
//=======================================================================
void Partition_Loop3d::AddConstFaces(const TopoDS_Shape& S)
{
TopExp_Explorer FaceExp(S, TopAbs_FACE);
for (; FaceExp.More(); FaceExp.Next())
myFaces.Append( FaceExp.Current() );
TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, myEFMap);
}
//=======================================================================
//function : AddSectionFaces
//purpose : Add faces of <S> as double faces in the result.
//=======================================================================
void Partition_Loop3d::AddSectionFaces(const TopoDS_Shape& S)
{
AddConstFaces( S );
AddConstFaces( S.Reversed() );
}
//=======================================================================
//function : MakeShells
//purpose : Make and return shells.
// <AvoidFacesMap> can contain faces that must not be
// added to result shells.
//=======================================================================
const TopTools_ListOfShape&
Partition_Loop3d::MakeShells (const TopTools_MapOfOrientedShape& AvoidFacesMap)
{
myNewShells.Clear();
BRep_Builder Builder;
TopTools_MapOfShape CheckedEdgesMap;
TopTools_MapOfOrientedShape AddedFacesMap;
TopTools_ListIteratorOfListOfShape itF (myFaces);
for (; itF.More(); itF.Next())
{
const TopoDS_Shape& FF = itF.Value();
if (AvoidFacesMap.Contains( FF ) ||
! AddedFacesMap.Add( FF ) )
continue;
// make a new shell
TopoDS_Shell Shell;
Builder.MakeShell(Shell);
Builder.Add(Shell,FF);
// clear the maps from shapes added to previous Shell
TopTools_MapIteratorOfMapOfShape itEM (CheckedEdgesMap);
for (; itEM.More(); itEM.Next()) {
TopTools_ListOfShape& FL = myEFMap.ChangeFromKey( itEM.Key());
TopTools_ListIteratorOfListOfShape it (FL);
while ( it.More()) {
if (AddedFacesMap.Contains( it.Value()))
FL.Remove( it );
else
it.Next();
}
}
CheckedEdgesMap.Clear();
// loop on faces added to Shell; add their neighbor faces to Shell and so on
TopoDS_Iterator itAddedF (Shell);
for (; itAddedF.More(); itAddedF.Next())
{
const TopoDS_Face& F = TopoDS::Face (itAddedF.Value());
// loop on edges of F; find a good neighbor face of F by E
TopExp_Explorer EdgeExp(F, TopAbs_EDGE);
for (; EdgeExp.More(); EdgeExp.Next())
{
const TopoDS_Edge& E = TopoDS::Edge( EdgeExp.Current());
if (! CheckedEdgesMap.Add( E ))
continue;
// candidate faces list
const TopTools_ListOfShape& FL = myEFMap.ChangeFromKey(E);
if (FL.IsEmpty())
continue;
// select one of neighbors
TopoDS_Face SelF;
if (FL.Extent() == 2) {
if (! F.IsSame( FL.First() ))
SelF = TopoDS::Face( FL.First() );
else if (!F.IsSame( FL.Last() ))
SelF = TopoDS::Face( FL.Last() );
}
else {
// check if a face already added to Shell shares E
TopTools_ListIteratorOfListOfShape it (FL);
Standard_Boolean found = Standard_False;
for (; !found && it.More(); it.Next())
if (F != it.Value())
found = AddedFacesMap.Contains( it.Value() );
if (found)
continue;
// select basing on geometrical check
Standard_Boolean GoodOri, inside;
Standard_Real dot, MaxDot = -100;
TopTools_ListOfShape TangFL; // tangent faces
for ( it.Initialize( FL ) ; it.More(); it.Next()) {
const TopoDS_Face& NeighborF = TopoDS::Face( it.Value());
if (NeighborF.IsSame( F ))
continue;
inside = Partition_Loop3d::IsInside( E, F, NeighborF, 1, dot, GoodOri);
if (!GoodOri)
continue;
if (!inside)
dot = -dot - 3;
if (dot < MaxDot)
continue;
if ( IsEqual( dot, MaxDot))
TangFL.Append(SelF);
else
TangFL.Clear();
MaxDot = dot;
SelF = NeighborF;
}
if (!TangFL.IsEmpty()) {
for (it.Initialize( TangFL ); it.More(); it.Next()) {
const TopoDS_Face& NeighborF = TopoDS::Face( it.Value());
if (Partition_Loop3d:: IsInside( E, SelF , NeighborF, 0, dot, GoodOri))
SelF = NeighborF;
}
}
}
if (!SelF.IsNull() &&
AddedFacesMap.Add( SelF ) &&
!AvoidFacesMap.Contains( SelF ))
Builder.Add( Shell, SelF);
} // loop on edges of F
} // loop on the faces added to Shell
// Shell is complete
myNewShells.Append( Shell );
} // loop on myFaces
// prepare to the next call
myFaces.Clear();
myEFMap.Clear();
return myNewShells;
}
//=======================================================================
//function : Normal
//purpose :
//=======================================================================
gp_Vec Partition_Loop3d::Normal(const TopoDS_Edge& E,
const TopoDS_Face& F)
{
gp_Vec Norm, V1, V2;
Standard_Real First, Last;
gp_Pnt Ps;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last);
Handle(Geom_Surface) Sf = BRep_Tool::Surface(F);
gp_Pnt2d p = C2d->Value( 0.5*(First+Last) );
Sf->D1(p.X(), p.Y(), Ps, V1, V2);
Norm = V1.Crossed(V2);
if (F.Orientation() == TopAbs_REVERSED )
Norm.Reverse();
return Norm;
}
//=======================================================================
//function : NextNormal
//purpose : find normal to F at point a little inside F near the middle of E
//warning : E must be properly oriented in F.
//=======================================================================
static gp_Vec NextNormal(const TopoDS_Edge& E,
const TopoDS_Face& F)
{
Standard_Real First, Last;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last);
Handle(Geom_Surface) Sf = BRep_Tool::Surface(F);
gp_Pnt2d p;
gp_Vec2d v;
C2d->D1( 0.5*(First+Last), p, v);
if (E.Orientation() != F.Orientation())
v.Reverse();
gp_Dir2d dir( -v.Y(), v.X() ); // dir inside F
Standard_Real duv = 1e-6; // this is not Ok and may give incorrect result if
// resolutionUV of compared faces is very different. To have a good result,
//it is necessary to get normal to faces at points equidistant from E in 3D
p.SetX( p.X() + dir.X()*duv );
p.SetY( p.Y() + dir.Y()*duv );
gp_Pnt Ps;
gp_Vec Norm, V1, V2, VV1, VV2;
Sf->D1( p.X(), p.Y(), Ps, V1, V2);
Norm = V1.Crossed(V2);
if (F.Orientation() == TopAbs_REVERSED )
Norm.Reverse();
return Norm;
}
//=======================================================================
//function : FindEinF
//purpose : find E in F
//=======================================================================
static TopoDS_Edge FindEinF(const TopoDS_Edge& E,
const TopoDS_Face& F)
{
TopExp_Explorer expl (F, TopAbs_EDGE);
for (; expl.More(); expl.Next())
if( E.IsSame( expl.Current() ))
return TopoDS::Edge(expl.Current());
TopoDS_Edge nullE;
return nullE;
}
//=======================================================================
//function : IsInside
//purpose : check if <F2> is inside <F1> by edge <E>.
// if <CountDot>, compute <Dot>: scalar production of
// normalized vectors pointing inside faces, and
// check if faces are oriented well for sewing
//=======================================================================
Standard_Boolean Partition_Loop3d::IsInside(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const Standard_Boolean CountDot,
Standard_Real& Dot,
Standard_Boolean& GoodOri)
{
Standard_Real f, l;
gp_Pnt P;
gp_Vec Vc1, Vc2, Vin1, Vin2, Nf1, Nf2;
Handle(Geom_Curve) Curve = BRep_Tool::Curve(E,f,l);
Curve->D1( 0.5*(f + l), P, Vc2);
TopoDS_Edge E1, E2 = FindEinF (E, F2);
if (E2.Orientation() == TopAbs_REVERSED ) Vc2.Reverse();
Nf1 = Normal(E,F1);
Nf2 = Normal(E,F2);
Standard_Real sin =
Nf1.CrossSquareMagnitude(Nf2) / Nf1.SquareMagnitude() / Nf2.SquareMagnitude();
Standard_Boolean tangent = sin < 0.001;
Standard_Boolean inside = 0;
if (tangent) {
E1 = FindEinF (E, F1);
gp_Vec NNf1 = NextNormal(E1,F1);
gp_Vec NNf2 = NextNormal(E2,F2);
Vin2 = NNf2.Crossed(Vc2);
inside = Vin2 * NNf1 < 0;
}
else {
Vin2 = Nf2.Crossed(Vc2);
inside = Vin2 * Nf1 < 0;
}
if (!CountDot) return inside;
if (tangent)
Vin2 = Nf2.Crossed(Vc2);
else
E1 = FindEinF (E, F1);
Vc1 = Vc2;
if (E1.Orientation() != E2.Orientation())
Vc1.Reverse();
Vin1 = Nf1.Crossed(Vc1);
if (tangent) {
Standard_Real N1N2 = Nf1 * Nf2;
GoodOri = (Vin2 * Vin1 < 0) ? N1N2 > 0 : N1N2 < 0;
}
else {
Standard_Real V1N2 = Vin1 * Nf2;
GoodOri = ( inside ? V1N2 <= 0 : V1N2 >= 0);
}
Vin1.Normalize();
Vin2.Normalize();
Dot = Vin2 * Vin1;
return inside;
}

View File

@ -1,102 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
//
//
// File : Partition_Loop3d.hxx
// Module : GEOM
#ifndef _Partition_Loop3d_HeaderFile
#define _Partition_Loop3d_HeaderFile
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
class TopoDS_Shape;
class TopTools_ListOfShape;
class TopTools_MapOfOrientedShape;
class TopoDS_Edge;
class TopoDS_Face;
class gp_Vec;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class Partition_Loop3d {
public:
void* operator new(size_t,void* anAddress)
{
return anAddress;
}
void* operator new(size_t size)
{
return Standard::Allocate(size);
}
void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// Methods PUBLIC
//
Standard_EXPORT Partition_Loop3d();
Standard_EXPORT void AddConstFaces(const TopoDS_Shape& S) ;
Standard_EXPORT void AddSectionFaces(const TopoDS_Shape& S) ;
Standard_EXPORT const TopTools_ListOfShape& MakeShells(const TopTools_MapOfOrientedShape& AvoidFacesMap) ;
Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const Standard_Boolean CountDot,Standard_Real& Dot,Standard_Boolean& GoodOri) ;
Standard_EXPORT static gp_Vec Normal(const TopoDS_Edge& E,const TopoDS_Face& F) ;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
TopTools_ListOfShape myNewShells;
TopTools_ListOfShape myFaces;
TopTools_IndexedDataMapOfShapeListOfShape myEFMap;
};
// other Inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -1,14 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
//
//
// File : Partition_Loop3d.ixx
// Module : GEOM
#include "Partition_Loop3d.jxx"

View File

@ -1,30 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
//
//
// File : Partition_Loop3d.jxx
// Module : GEOM
#ifndef _TopoDS_Shape_HeaderFile
#include <TopoDS_Shape.hxx>
#endif
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _TopTools_MapOfOrientedShape_HeaderFile
#include <TopTools_MapOfOrientedShape.hxx>
#endif
#ifndef _TopoDS_Edge_HeaderFile
#include <TopoDS_Edge.hxx>
#endif
#ifndef _TopoDS_Face_HeaderFile
#include <TopoDS_Face.hxx>
#endif
#ifndef _gp_Vec_HeaderFile
#include <gp_Vec.hxx>
#endif
#ifndef _Partition_Loop3d_HeaderFile
#include "Partition_Loop3d.hxx"
#endif

View File

@ -1,165 +0,0 @@
-- GEOM PARTITION : partition algorithm
--
-- Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
--
--
--
-- File : Partition_Spliter.cdl
-- Author : Benedicte MARTIN
-- Module : GEOM
class Spliter from Partition
---Purpose: Split solids, shells and faces into parts of the
-- same topology if reconstruction level is not
-- limited.
uses
Inter3d from Partition,
Loop2d from Partition,
Builder from BRep,
ShapeEnum from TopAbs,
Compound from TopoDS,
Face from TopoDS,
Edge from TopoDS,
Shape from TopoDS,
MapOfOrientedShape from TopTools,
IndexedMapOfShape from TopTools,
DataMapOfShapeShape from TopTools,
ListOfShape from TopTools,
MapOfShape from TopTools,
AsDes from BRepAlgo,
Image from BRepAlgo
is
Create returns Spliter from Partition;
---Purpose: constructor
AddShape ( me : in out; S : Shape from TopoDS);
---Purpose: add object Shape to be splitted.
-- If S is a COMPOUND or COMPSOLID, it will be
-- exploded in order to get more simple object
-- shapes.
-- Object shapes that are vertices, edges or wires
-- won't be splitted and won't be in a result.
AddTool ( me : in out; S : Shape from TopoDS);
---Purpose: add cutting tool
Compute (me : in out; Limit : ShapeEnum from TopAbs
= TopAbs_SHAPE);
---Purpose: produce a result which is a compound of parts of
-- object shapes. A part can be either a vertex,
-- edge, wire, face, shell or solid.
-- By default, a part is of the same topology as an
-- object shape, else <Limit> restricts parts
-- reconstruction.
-- If <Limit> == TopAbs_VERTEX, only new vertices are
-- returned in the result
KeepShapesInside (me : in out; S : Shape from TopoDS);
---Purpose: remove shapes that are outside of S from result.
-- S should be an object shape.
---Warning: call it after Compute()
RemoveShapesInside (me : in out; S : Shape from TopoDS);
---Purpose: remove shapes that are inside S from result.
-- S should be an object shape.
---Warning: call it after Compute()
Shape ( me ) returns Shape from TopoDS;
---Purpose: return resulting compound
Clear ( me : in out);
---Purpose: clear fields
---Category: private methods
MakeShells (me: in out; S : Shape from TopoDS;
NS: in out ListOfShape from TopTools) is private;
---Purpose: split S into shells
MakeFaces (me: in out; S : Shape from TopoDS)
returns Shape from TopoDS is private;
---Purpose: split faces of S, return compound of new faces
MakeEdges (me;
E : Edge from TopoDS;
VOnE : ListOfShape from TopTools;
NE : in out ListOfShape from TopTools)
is private;
---Purpose: cut E by vertices VOnE, return list of new edges
-- NE
FindFacesInside (me: in out; S : Shape from TopoDS;
CheckClosed : Boolean = Standard_False;
All : Boolean = Standard_False)
returns Shape from TopoDS is private;
---Purpose: return compound of faces of other shapes that are
-- inside <S>. <S> must have image in myImageShape.
-- <CheckClosed> makes avoid faces that do not form a
-- closed shell
-- <All> makes return already added faces
CheckTool ( me: in out; S : Shape from TopoDS)
returns Boolean from Standard is private;
---Purpose: Return True if <S> is a tool shape. Prepare tool
-- faces of <S> for the search of internal faces.
MergeEqualEdges (me: in out; LE : ListOfShape from TopTools) is private;
---Purpose: among LE, find equal edges, choose ones to keep
-- and make them have pcurves on all faces they are
-- shared by
-- <LE> contains edge splits
fields
myDoneStep : ShapeEnum from TopAbs; -- reconstructed topology
myShape : Compound from TopoDS; -- result
myBuilder : Builder from BRep;
myListShapes : ListOfShape from TopTools; -- object shapes
myMapFaces : MapOfShape from TopTools; -- object faces
myMapTools : MapOfShape from TopTools; -- tool faces
myFaceShapeMap : DataMapOfShapeShape from TopTools; -- to find a shape by face
myNewSection : MapOfShape from TopTools; -- new secton edges
myAsDes : AsDes from BRepAlgo;
myImagesFaces : Image from BRepAlgo;
myImagesEdges : Image from BRepAlgo;
myImageShape : Image from BRepAlgo;
-- contains info of same domain shapes and section edges
myInter3d : Inter3d from Partition;
-- avoid rebuilding twice commont part of solids
myAddedFacesMap: MapOfOrientedShape from TopTools;
-- equal splits
myEqualEdges : MapOfShape from TopTools;
-- shape and its internal faces
myInternalFaces: DataMapOfShapeShape from TopTools;
myIntNotClFaces: DataMapOfShapeShape from TopTools;-- internal but not closed
end Spliter;

File diff suppressed because it is too large Load Diff

View File

@ -1,161 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Spliter.hxx
// Module : GEOM
#ifndef _Partition_Spliter_HeaderFile
#define _Partition_Spliter_HeaderFile
#ifndef _TopAbs_ShapeEnum_HeaderFile
#include <TopAbs_ShapeEnum.hxx>
#endif
#ifndef _TopoDS_Compound_HeaderFile
#include <TopoDS_Compound.hxx>
#endif
#ifndef _BRep_Builder_HeaderFile
#include <BRep_Builder.hxx>
#endif
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _TopTools_MapOfShape_HeaderFile
#include <TopTools_MapOfShape.hxx>
#endif
#ifndef _TopTools_DataMapOfShapeShape_HeaderFile
#include <TopTools_DataMapOfShapeShape.hxx>
#endif
#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
#include <Handle_BRepAlgo_AsDes.hxx>
#endif
#ifndef _BRepAlgo_Image_HeaderFile
#include <BRepAlgo_Image.hxx>
#endif
#ifndef _Partition_Inter3d_HeaderFile
#include "Partition_Inter3d.hxx"
#endif
#ifndef _TopTools_MapOfOrientedShape_HeaderFile
#include <TopTools_MapOfOrientedShape.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
class BRepAlgo_AsDes;
class TopoDS_Shape;
class TopTools_ListOfShape;
class TopoDS_Edge;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class Partition_Spliter {
public:
void* operator new(size_t,void* anAddress)
{
return anAddress;
}
void* operator new(size_t size)
{
return Standard::Allocate(size);
}
void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// Methods PUBLIC
//
Standard_EXPORT Partition_Spliter();
Standard_EXPORT void AddShape(const TopoDS_Shape& S) ;
Standard_EXPORT void AddTool(const TopoDS_Shape& S) ;
Standard_EXPORT void Compute(const TopAbs_ShapeEnum Limit = TopAbs_SHAPE) ;
Standard_EXPORT void KeepShapesInside(const TopoDS_Shape& S) ;
Standard_EXPORT void RemoveShapesInside(const TopoDS_Shape& S) ;
Standard_EXPORT TopoDS_Shape Shape() const;
Standard_EXPORT void Clear() ;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
Standard_EXPORT void MakeShells(const TopoDS_Shape& S,TopTools_ListOfShape& NS) ;
Standard_EXPORT TopoDS_Shape MakeFaces(const TopoDS_Shape& S) ;
Standard_EXPORT void MakeEdges(const TopoDS_Edge& E,const TopTools_ListOfShape& VOnE,TopTools_ListOfShape& NE) const;
Standard_EXPORT TopoDS_Shape FindFacesInside(const TopoDS_Shape& S,const Standard_Boolean CheckClosed = Standard_False,const Standard_Boolean All = Standard_False) ;
Standard_EXPORT Standard_Boolean CheckTool(const TopoDS_Shape& S) ;
Standard_EXPORT void MergeEqualEdges(const TopTools_ListOfShape& LE) ;
// Fields PRIVATE
//
TopAbs_ShapeEnum myDoneStep;
TopoDS_Compound myShape;
BRep_Builder myBuilder;
TopTools_ListOfShape myListShapes;
TopTools_MapOfShape myMapFaces;
TopTools_MapOfShape myMapTools;
TopTools_DataMapOfShapeShape myFaceShapeMap;
TopTools_MapOfShape myNewSection;
Handle_BRepAlgo_AsDes myAsDes;
BRepAlgo_Image myImagesFaces;
BRepAlgo_Image myImagesEdges;
BRepAlgo_Image myImageShape;
Partition_Inter3d myInter3d;
TopTools_MapOfOrientedShape myAddedFacesMap;
TopTools_MapOfShape myEqualEdges;
TopTools_DataMapOfShapeShape myInternalFaces;
TopTools_DataMapOfShapeShape myIntNotClFaces;
};
// other Inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -1,31 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Spliter.ixx
// Module : GEOM
#include "Partition_Spliter.jxx"

View File

@ -1,41 +0,0 @@
// GEOM PARTITION : partition algorithm
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Partition_Spliter.jxx
// Module : GEOM
#ifndef _BRepAlgo_AsDes_HeaderFile
#include <BRepAlgo_AsDes.hxx>
#endif
#ifndef _TopoDS_Shape_HeaderFile
#include <TopoDS_Shape.hxx>
#endif
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
#endif
#ifndef _TopoDS_Edge_HeaderFile
#include <TopoDS_Edge.hxx>
#endif
#ifndef _Partition_Spliter_HeaderFile
#include "Partition_Spliter.hxx"
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,201 +0,0 @@
// GEOM SKETCHER : basic sketcher
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_Sketcher.h
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
#include "GEOM_SketcherStatus.h"
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <Geom_Plane.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
#include <AIS_Axis.hxx>
#include <TopoDS_Edge.hxx>
#include <AIS_LengthDimension.hxx>
#include <AIS_RadiusDimension.hxx>
#include <AIS_AngleDimension.hxx>
#include <Geom2d_Line.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <TColgp_SequenceOfPnt2d.hxx>
#include <gp_Vec2d.hxx>
class Sketch
{
public:
Sketch();
~Sketch();
Sketch(const Handle(V3d_Viewer)& aViewer);
Sketch(const Handle(V3d_Viewer)& aViewer,
const Quantity_Color& anAxisColor,
const Quantity_Color& aCurrentColor,
const Quantity_Color& aWireColor);
static void fitInResol(Standard_Real &toFit,
Standard_Boolean minIsResol = Standard_False);
void MakeCurrentEdge(const Standard_Integer Xp ,
const Standard_Integer Yp ,
const Handle(V3d_View)& aView );
void MakeCurrentEdge(const Standard_Real X, const Standard_Real Y);
Standard_Boolean SetDimension(Standard_Real& aValue);
void SetDimension(Standard_Real& deltaX,Standard_Real& deltaY);
void SetXDimension(Standard_Real& deltaX);
void SetYDimension(Standard_Real& deltaY);
void SetSegmentAngle(Standard_Real& aValue);
Standard_Real GetSegmentAngle();
void ValidateEdge();
TopoDS_Wire Close();
TopoDS_Wire End();
void Clear();
Standard_Boolean Delete();
void SetPlane(const Handle(Geom_Plane)& aPlane);
void SetWireColor(const Quantity_Color& aColor);
void SetCurrentColor(const Quantity_Color& aColor);
void SetAxisColor(const Quantity_Color& aColor);
void SetParameterVisibility(const TypeOfParameter atype,
const Standard_Boolean OnOff);
void HiligthWithColor(const TypeOfParameter atype,
const Quantity_NameOfColor acolor);
void Unhiligth(const TypeOfParameter atype);
Standard_Boolean IsValidCurrentParameter(const TypeOfParameter atype);
void SetParameterValue(const TypeOfParameter atype, Standard_Real aValue);
void ChangeMode(const SketchStatus aMode);
void SetTransitionStatus(const TransitionStatus aStatus);
SketchStatus GetCurrentStatus();
Standard_Integer GetmyEdgesNumber();
private :
void Init();
void MakeCurrentSegment(Standard_Real X, Standard_Real Y);
void MakeCurrentArc(Standard_Real X, Standard_Real Y);
void DisplayCurrentEdge();
void DisplayLengthDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
void DisplayXDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
void DisplayYDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
void DisplayAngleDimension();
void DisplayRadiusDimension();
void AddEdgeToWire();
void RemoveLastEdge();
void CreateConstraints();
private:
// Current status of construction
SketchStatus myCurrentStatus;
// Transition status between arcs and segments
TransitionStatus myTransitionStatus;
// Current wire
BRepBuilderAPI_MakeWire myCurrentWire;
// Current presentable wire
Handle_AIS_Shape myPresentableWire;
// Number of edges into the current wire
Standard_Integer myEdgesNumber;
// Store for each edge how it has been built i.d the value of myCurrentStatus
TColStd_SequenceOfInteger myConstructionMode;
// Store for each edge how it has been built i.d the value of myTransitionStatus
TColStd_SequenceOfInteger myConstraintMode;
// Current edge
TopoDS_Shape myCurrentEdge;
// Previous edge
TopoDS_Edge myPreviousEdge;
// List of points to interpolate when computing a curve by interpolation
TColgp_SequenceOfPnt2d myPointsToInterpolate;
// Tangent vector at beginning of curve
gp_Vec2d myTangentVector;
// Tangent flag at beginning og curve
Standard_Boolean myTangentFlag;
// Origin of sketch
TopoDS_Vertex myFirstPointSketch;
// Last x coordinate of end point of previous edge or picked point
Standard_Real myLastX;
// Last y coordinate of end point of previous edge or picked point
Standard_Real myLastY;
// angle between 2 segments when an ANGLE TransitionStatus is set.
Standard_Real mySegmentAngle;
// Length of segment when the length of the segment is fixed before the angle
Standard_Real mySegmentLength;
// Value of X fixed coordinate
Standard_Real mySegmentX;
// Value of Y fixed Coordinate
Standard_Real mySegmentY;
Handle_AIS_Shape myPresentableEdge; // Current presentable edge
Handle_AIS_LengthDimension myLengthDimension;// For display of current length segment dimension
Handle_AIS_LengthDimension myXDimension; // For display of current X segment dimension
Handle_AIS_LengthDimension myYDimension; // For display of current Y segment dimension
Handle_AIS_LengthDimension myRadiusDimension;// For display of current radius dimension
Handle_AIS_AngleDimension myAngleDimension; // For display of current angle dimension
Standard_Boolean myIsLengthDimensionVisible; // Visibility flag for LengthDimension
Standard_Boolean myIsXDimensionVisible; // Visibility flag for X Dimension
Standard_Boolean myIsYDimensionVisible; // Visibility flag for Y Dimension
Standard_Boolean myIsRadiusDimensionVisible; // Visibility flag for RadiusDimension
Standard_Boolean myIsAngleDimensionVisible; // Visibility flag for AngleDimension
Handle_AIS_Axis myPresentableMediatrice; // Chord mediatrice of current circle as a presentable object
Handle_Geom2d_Line myMediatrice; // Chord mediatrice of current circle as a 2d line
Handle_AIS_Shape myCenterCircle; // to visualise center of current arc
Handle_AIS_Axis myHAxis; // Horizontal axis
Handle_AIS_Axis myVAxis; // Vertical axis
Handle_AIS_Axis myAngularAxis; // Axis making a predefined angle with the previous edge
Quantity_Color myWireColor; // Color of wire and of build edges
Quantity_Color myCurrentColor; // Color of edge under construction
Quantity_Color myAxisColor; // Color for axis
Handle_AIS_InteractiveContext myInteractiveContext; // Interactive context for display management
Handle_Geom_Plane myPlane; // Plane of sketch
BRepBuilderAPI_MakeWire myPasteWire;
Standard_Integer myPasteEdgesNumber;
TColStd_SequenceOfInteger myPasteConstructionMode;
TColStd_SequenceOfInteger myPasteConstraintMode;
};

View File

@ -1,53 +0,0 @@
// GEOM SKETCHER : basic sketcher
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_SketcherStatus.h
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
enum TransitionStatus {
NOCONSTRAINT, // no constraint between consecutive edges
TANGENT, // arc and segment are tangent
PERPENDICULAR,// arc is tangent to the perpendicular to the segment
ANGLE, // Angular constraint between 2 segments
LENGTH_FIXED, // Length of segment has been fixed
X_FIXED, // X coordinate for segment has been fixed
Y_FIXED // Y coordinate for segment has been fixed
};
enum TypeOfParameter {
ANGLE_PARAMETER,
LENGTH_PARAMETER,
RADIUS_PARAMETER,
XVALUE_PARAMETER,
YVALUE_PARAMETER
};
enum SketchStatus {
BEGIN_SKETCH, // Begin sketch; no edges created yet
SEGMENT, // Current mode for creation is segment
ARC_CHORD, // Current mode for creation is arc by chord
ARC_CHORD_END,// Chord validated, waiting for radius or center
END_SKETCH // End sketch
};

View File

@ -1,58 +0,0 @@
# GEOM SKETCHER : basic sketcher
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Author : Patrick GOLDBRONN (CEA)
# Module : GEOM
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
# Libraries targets
LIB = libGeometrySketcher.la
LIB_SRC = GEOM_Sketcher.cxx
LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl
# header files
EXPORT_HEADERS= GEOM_Sketcher.h \
GEOM_SketcherStatus.h
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES)
CXXFLAGS += $(OCC_CXXFLAGS)
LDFLAGS += $(OCC_LIBS)
# additional file to be cleaned
MOSTLYCLEAN =
CLEAN =
DISTCLEAN =
@CONCLUDE@