From: nri Date: Mon, 12 May 2003 15:09:12 +0000 (+0000) Subject: NRI : First integration. X-Git-Tag: Start-v1_1a~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=84c3161ed5472836f47a0ae22ea147c237c2e97c;p=modules%2Fgeom.git NRI : First integration. --- diff --git a/src/GEOMClient/GEOM_Client.cxx b/src/GEOMClient/GEOM_Client.cxx new file mode 100644 index 000000000..ac8d7acf8 --- /dev/null +++ b/src/GEOMClient/GEOM_Client.cxx @@ -0,0 +1,233 @@ +using namespace std; +// File : GEOM_Client.cxx +// Created : +// Author : Yves FRICAUD/Lucien PIGNOLONI +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE +// $Header$ + +#include "GEOM_Client.hxx" +#include +#include "utilities.h" + +#include CORBA_SERVER_HEADER(GEOM_Gen) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +//======================================================================= +// function : Load() +// purpose : +//======================================================================= +static TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape ) +{ + TopoDS_Shape S; + /* get sequence of bytes of resulting brep shape from GEOM server */ + GEOM::GEOM_Shape::TMPFile_var SeqFile = aShape->GetShapeStream(); + int sizebuf = SeqFile->length(); + char* buf; + buf = (char*) &SeqFile[0]; + istrstream streamBrep(buf,sizebuf); + BRep_Builder aBuilder; + BRepTools::Read(S, streamBrep, aBuilder); + return S; +} + + +//======================================================================= +// function : Create() +// purpose : +//======================================================================= +GEOM_Client::GEOM_Client() +{ +} + + +//======================================================================= +// function : Find() +// purpose : +//======================================================================= +Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) +{ + for ( Standard_Integer i = 1; i<= myIORs.Length(); i++ ) { + if (myIORs.Value(i).IsEqual(IOR)) { + S = myShapes.Value(i); + return i; + } + } + return 0; +} + + +//======================================================================= +// function : Bind() +// purpose : +//======================================================================= +void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S ) +{ + myIORs.Append(IOR); + myShapes.Append(S); +} + +//======================================================================= +// function : RemoveShapeFromBuffer() +// purpose : Remove shape from Client Buffer +//======================================================================= +void GEOM_Client::RemoveShapeFromBuffer( const TCollection_AsciiString& shapeIOR ) +{ + if( myIORs.IsEmpty() ) + return ; + + TopoDS_Shape S ; + Standard_Integer anIndex = Find( shapeIOR, S ) ; + if( anIndex != 0 ) { + myIORs.Remove(anIndex) ; + myShapes.Remove(anIndex) ; + } + return ; +} + + +//======================================================================= +// function : ClearClientBuffer() +// purpose : purge buffer +//======================================================================= +void GEOM_Client::ClearClientBuffer() +{ + if( myIORs.IsEmpty() ) + return ; + myIORs.Clear() ; + myShapes.Clear() ; + return ; +} + +//======================================================================= +// function : BufferLength() +// purpose : +//======================================================================= +unsigned int GEOM_Client::BufferLength() +{ + return myIORs.Length() ; +} + + +//======================================================================= +// function : GetShape() +// purpose : +//======================================================================= + +TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape ) +{ + + TopoDS_Shape S; + TCollection_AsciiString IOR(aShape->Name()); + Standard_Integer anIndex = Find(IOR, S); + + BRep_Builder B; + + if (anIndex !=0 ) { + return S ; + } + + /******* in case of a MAIN GEOM::SHAPE ********/ + if (aShape->IsMainShape()) { + S = Load(geom, aShape); + Bind(IOR,S); + return S; + } + + /******* in case of SUB GEOM::SHAPE ***********/ + // Load and Explore the Main Shape + TopoDS_Shape MainShape = GetShape (geom, geom->GetIORFromString(aShape->MainName())); + GEOM::GEOM_Shape::ListOfSubShapeID_var list = aShape->Index(); + + Standard_Integer j = 1; + TopExp_Explorer exp; + TopAbs_ShapeEnum ShapeType = TopAbs_ShapeEnum(aShape->ShapeType()); + + /* Case of only one subshape */ + if (list->length() == 1) + { + if (ShapeType == TopAbs_COMPOUND) + { + TopoDS_Iterator it; + TopTools_ListOfShape CL; + CL.Append( MainShape ); + TopTools_ListIteratorOfListOfShape itC; + for (itC.Initialize( CL ); itC.More(); itC.Next()) + { + for (it.Initialize( itC.Value() ); it.More(); it.Next()) + { + if ( it.Value().ShapeType() == TopAbs_COMPOUND) + { + if (j == list[0]) + { + S = it.Value(); + Bind(IOR, S); + return S; + } + j++; + CL.Append( it.Value() ); + } + } + } + } + else + { + TopTools_MapOfShape M; + for (exp.Init(MainShape, ShapeType); exp.More(); exp.Next()) { + if ( M.Add(exp.Current()) ) + { + if (j == list[0]) + { + S = exp.Current(); + Bind(IOR, S); + return S; + } + j++; + } + } + } + } + + /* Case of a compound containing two or more sub shapes (not a main shape compound !) */ + + /* Warning : the compound when representing sub shapes must be explored in a sub type */ + /* that is NOT ShapeType=aShape->ShapeType()= TopAbs_COMPOUND ! */ + /* We have to retrieve the exact sub type of shapes contained in the compound first ! */ + TopoDS_Iterator it ; + TopAbs_ShapeEnum exactSubType ; + S = Load( geom, aShape ); + it.Initialize( S, true, true ) ; + it.More(); + exactSubType = it.Value().ShapeType() ; + + TColStd_MapOfInteger MapIndex; + Standard_Integer nbSS = list->length(); + TopoDS_Compound Comp; + B.MakeCompound(Comp); + + for (Standard_Integer i=1; i<=nbSS; i++) + MapIndex.Add(list[i-1]); + + for (exp.Init(MainShape, exactSubType), j=1; exp.More() ; exp.Next(), j++) { + if ( MapIndex.Contains(j) ) { + B.Add( Comp, exp.Current() ); + } + } + Bind(IOR, Comp); + return Comp; +} diff --git a/src/GEOMClient/GEOM_Client.hxx b/src/GEOMClient/GEOM_Client.hxx new file mode 100644 index 000000000..1f2df40f3 --- /dev/null +++ b/src/GEOMClient/GEOM_Client.hxx @@ -0,0 +1,73 @@ +// File : GEOM_Client.hxx +// Created : +// Author : Yves FRICAUD +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE +// $Header$ + +#ifndef _GEOM_Client_HeaderFile +#define _GEOM_Client_HeaderFile + +#include +#include CORBA_SERVER_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(GEOM_Gen) +# +#ifndef _TColStd_SequenceOfAsciiString_HeaderFile +#include +#endif +#ifndef _TopTools_SequenceOfShape_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +class TCollection_AsciiString; +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +//===================================================================== +// GEOM_Client : class definition +//===================================================================== +class GEOM_Client { + +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); + } + // Methods PUBLIC + // + Standard_EXPORT GEOM_Client(); + Standard_EXPORT Standard_Integer Find( const TCollection_AsciiString& ShapeIOR, TopoDS_Shape& S ) ; + Standard_EXPORT void Bind( const TCollection_AsciiString& ShapeIOR, const TopoDS_Shape& S ) ; + Standard_EXPORT TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape ); + Standard_EXPORT void RemoveShapeFromBuffer( const TCollection_AsciiString& shapeIOR ) ; + Standard_EXPORT void ClearClientBuffer() ; + Standard_EXPORT unsigned int BufferLength() ; + +private: + // Fields PRIVATE + // + TColStd_SequenceOfAsciiString myIORs ; + TopTools_SequenceOfShape myShapes ; +}; + + +#endif diff --git a/src/GEOMClient/Makefile.in b/src/GEOMClient/Makefile.in new file mode 100644 index 000000000..47cd81639 --- /dev/null +++ b/src/GEOMClient/Makefile.in @@ -0,0 +1,40 @@ +# -* Makefile *- +# +# Author : Patrick GOLDBRONN (CEA) +# Date : 29/06/2001 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:$(srcdir):${KERNEL_ROOT_DIR}/idl/salome + + +@COMMENCE@ + +# header files +EXPORT_HEADERS = \ + GEOM_Client.hxx + +# Libraries targets + +LIB = libGeometryClient.la +LIB_SRC = GEOM_Client.cxx +LIB_SERVER_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl + +# Executables targets +BIN = +BIN_SRC = +BIN_CLIENT_IDL = +BIN_SERVER_IDL = + +# additionnal information to compil and link file +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += $(OCC_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + + +@CONCLUDE@ + diff --git a/src/GEOMDS/GEOMDS.cdl b/src/GEOMDS/GEOMDS.cdl new file mode 100644 index 000000000..2a3862671 --- /dev/null +++ b/src/GEOMDS/GEOMDS.cdl @@ -0,0 +1,33 @@ +-- File: GEOMDS.cdl +-- Created: Fri Mar 16 12:16:40 2001 +-- Author: Yves FRICAUD +-- +---Copyright: Matra Datavision 2001 + + +package GEOMDS + + ---Purpose: + +uses + TDF, + TDocStd, + TDataStd, + TColStd, + TopoDS, + TCollection, + TNaming + + +is + class Application; + class Commands; + class Explorer; + + + class DataMapOfIntegerTransient instantiates DataMap from +TCollection(Integer from Standard, Transient from Standard, MapIntegerHasher +from TColStd); + +end GEOMDS; + diff --git a/src/GEOMDS/GEOMDS_Application.cdl b/src/GEOMDS/GEOMDS_Application.cdl new file mode 100644 index 000000000..2ab42672a --- /dev/null +++ b/src/GEOMDS/GEOMDS_Application.cdl @@ -0,0 +1,31 @@ +// File : GEOMDS_Application.cdl +// Created : +// Author : Yves FRICAUD +// Project : SALOME +// Module : GEOM +// Copyright : OPEN CASCADE +// $Header$ + + +class Application from GEOMDS inherits Application from TDocStd + + ---Purpose: + +uses + Label from TDF, + SequenceOfExtendedString from TColStd, + CString from Standard, + Document from TDocStd + + +is + + Create + returns mutable Application from GEOMDS; + + Formats(me: mutable; Formats: out SequenceOfExtendedString from TColStd) + is redefined; + + ResourcesName (me: mutable) returns CString from Standard; + +end Application; diff --git a/src/GEOMDS/GEOMDS_Application.cxx b/src/GEOMDS/GEOMDS_Application.cxx new file mode 100644 index 000000000..3b50dcd2b --- /dev/null +++ b/src/GEOMDS/GEOMDS_Application.cxx @@ -0,0 +1,47 @@ +using namespace std; +// File : GEOMDS_Application.cxx +// Created : +// Author : Yves FRICAUD +// Project : SALOME +// Module : GEOM +// Copyright : OPEN CASCADE +// $Header$ + + +#include "GEOMDS_Application.ixx" + +//======================================================================= +//function : GEOMDS_Application +//purpose : +//======================================================================= + +GEOMDS_Application::GEOMDS_Application() +{ +} + + +//======================================================================= +//function : Formats +//purpose : +//======================================================================= + +void GEOMDS_Application::Formats(TColStd_SequenceOfExtendedString& Formats) +{ + Formats.Append(TCollection_ExtendedString ("SALOME_GEOM")); +} + + +//======================================================================= +//function : ResourcesName +//purpose : +//======================================================================= + +Standard_CString GEOMDS_Application::ResourcesName() +{ + return Standard_CString ("Resources"); +} + + + + + diff --git a/src/GEOMDS/GEOMDS_Application.hxx b/src/GEOMDS/GEOMDS_Application.hxx new file mode 100644 index 000000000..23bdf144e --- /dev/null +++ b/src/GEOMDS/GEOMDS_Application.hxx @@ -0,0 +1,101 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _GEOMDS_Application_HeaderFile +#define _GEOMDS_Application_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_GEOMDS_Application_HeaderFile +#include +#endif + +#ifndef _TDocStd_Application_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif +class TColStd_SequenceOfExtendedString; + + +class GEOMDS_Application : public TDocStd_Application { + +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 GEOMDS_Application(); +Standard_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& Formats) ; +Standard_EXPORT Standard_CString ResourcesName() ; +Standard_EXPORT ~GEOMDS_Application(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOMDS_Application_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 + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMDS/GEOMDS_Application.ixx b/src/GEOMDS/GEOMDS_Application.ixx new file mode 100644 index 000000000..22e3c566a --- /dev/null +++ b/src/GEOMDS/GEOMDS_Application.ixx @@ -0,0 +1,74 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOMDS_Application.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +GEOMDS_Application::~GEOMDS_Application() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOMDS_Application_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDocStd_Application); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDocStd_Application); + static Handle_Standard_Type aType2 = STANDARD_TYPE(CDF_Application); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(CDF_Application); + static Handle_Standard_Type aType3 = STANDARD_TYPE(CDM_Application); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(CDM_Application); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("GEOMDS_Application", + sizeof(GEOMDS_Application), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +// DownCast method +// allow safe downcasting + + +const Handle(GEOMDS_Application) Handle(GEOMDS_Application)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMDS_Application) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMDS_Application))) { + _anOtherObject = Handle(GEOMDS_Application)((Handle(GEOMDS_Application)&)AnObject); + } + } + + return _anOtherObject ; +} + + +const Handle(Standard_Type)& GEOMDS_Application::DynamicType() const +{ + return STANDARD_TYPE(GEOMDS_Application) ; +} +Standard_Boolean GEOMDS_Application::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOMDS_Application) == AType || TDocStd_Application::IsKind(AType)); +} +Handle_GEOMDS_Application::~Handle_GEOMDS_Application() {} \ No newline at end of file diff --git a/src/GEOMDS/GEOMDS_Application.jxx b/src/GEOMDS/GEOMDS_Application.jxx new file mode 100644 index 000000000..85cd58d00 --- /dev/null +++ b/src/GEOMDS/GEOMDS_Application.jxx @@ -0,0 +1,6 @@ +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _GEOMDS_Application_HeaderFile +#include "GEOMDS_Application.hxx" +#endif diff --git a/src/GEOMDS/GEOMDS_Commands.cdl b/src/GEOMDS/GEOMDS_Commands.cdl new file mode 100644 index 000000000..d0b378e5f --- /dev/null +++ b/src/GEOMDS/GEOMDS_Commands.cdl @@ -0,0 +1,26 @@ +-- File: GEOMDS_Commands.cdl +-- Created: Fri Mar 16 12:21:51 2001 +-- Author: Yves FRICAUD +-- +---Copyright: Matra Datavision 2001 + + +class Commands from GEOMDS + + ---Purpose: + +uses + Label from TDF, + Shape from TopoDS, + ExtendedString from TCollection + +is + Create ( Main : Label from TDF) returns Commands from GEOMDS; + + AddShape(me : in out; S : Shape from TopoDS; + Name : ExtendedString from TCollection) + returns Label from TDF; + +fields + myLab : Label from TDF; +end Commands; diff --git a/src/GEOMDS/GEOMDS_Commands.cxx b/src/GEOMDS/GEOMDS_Commands.cxx new file mode 100644 index 000000000..da7ed8f3e --- /dev/null +++ b/src/GEOMDS/GEOMDS_Commands.cxx @@ -0,0 +1,282 @@ +using namespace std; +// File : GeomDS_Commands.cxx +// Created : +// Author : Yves FRICAUD/Lucien PIGNOLONI +// Project : SALOME +// Module : GEOM +// Copyright : OPEN CASCADE +// $Header$ + +#include "utilities.h" +#include "GEOMDS_Commands.ixx" + +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : GEOMDS_Commands +//purpose : +//======================================================================= +GEOMDS_Commands::GEOMDS_Commands(const TDF_Label& Main) + : myLab(Main) +{ +} + + +//======================================================================= +// function : Generated() +// purpose : +//======================================================================= +TDF_Label GEOMDS_Commands::Generated(const TopoDS_Shape& S, + const TCollection_ExtendedString& Name) +{ + TDF_Label NewLab = myLab.NewChild(); + TNaming_Builder B(NewLab); + B.Generated(S); + TDataStd_Name::Set(NewLab,Name); + return NewLab; +} + + + +//======================================================================= +// function : Generated() +// purpose : +//======================================================================= +TDF_Label GEOMDS_Commands::Generated(const TopoDS_Shape& S1, + const TopoDS_Shape& S2, + const TCollection_ExtendedString& Name) +{ + TDF_Label NewLab = myLab.NewChild(); + TNaming_Builder B(NewLab); + B.Generated(S1,S2); + TDataStd_Name::Set(NewLab,Name); + return NewLab; +} + + + +//======================================================================= +// function : AddShape() +// purpose : +//======================================================================= +TDF_Label GEOMDS_Commands::AddShape(const TopoDS_Shape& S, + const TCollection_ExtendedString& Name) +{ + TDF_Label NewLab = myLab.NewChild(); + TNaming_Builder B(NewLab); + B.Select(S,S); + TDataStd_Name::Set(NewLab,Name); + return NewLab; +} + + +//======================================================================= +// function : AddIndependentShape() +// purpose : SAME than AddShape() : will be renamed later +//======================================================================= +TDF_Label GEOMDS_Commands::AddIndependentShape(const TopoDS_Shape& S, + const TCollection_AsciiString& nameIOR) +{ + TDF_Label NewLab = myLab.NewChild(); + TNaming_Builder B(NewLab); + B.Select(S,S); + TDataStd_Name::Set(NewLab, nameIOR); + return NewLab; +} + + +//======================================================================= +// function : AddDependentShape() +// purpose : +//======================================================================= +TDF_Label GEOMDS_Commands::AddDependentShape(const TopoDS_Shape& S, + const TCollection_AsciiString& nameIOR, + const TDF_Label& mainLab) +{ + TDF_Label NewLab = myLab.NewChild(); + TNaming_Builder B(NewLab); + B.Select(S,S); + TDataStd_Name::Set(NewLab, nameIOR); + /* NewLab has a reference attribute to mainLab (the main shape in fact) */ + TDF_Reference::Set(NewLab, mainLab) ; + return NewLab; +} + + + +//======================================================================= +// function : AddConstructiveElement() +// purpose : +//======================================================================= +TDF_Label GEOMDS_Commands::AddConstructiveElement(const TopoDS_Shape& S, + const TCollection_ExtendedString& nameIOR, + const GEOMDS_ConstructiveType& aType) +{ + TDF_Label NewLab = myLab.NewChild(); + TNaming_Builder B(NewLab); + B.Select(S,S); + TDataStd_Name::Set(NewLab, nameIOR); + /* Add the Attribute Constructive Element coded with a TDataStd_Integer from an enum */ + TDataStd_Integer::Set(NewLab, Standard_Integer(aType)); + return NewLab; +} + + +//======================================================================= +// function : AddIORNameAttribute() +// purpose : Add attribute TDataStd_Name to a label +// : this attribute represents the name/IOR of object +// : Return false if attribute exist before +//======================================================================= +Standard_Boolean GEOMDS_Commands::AddIORNameAttribute(const TDF_Label& aLabel, + const TCollection_ExtendedString& nameIOR) +{ + if( this->HasIOR(aLabel) ) + return false ; + TDataStd_Name::Set(aLabel, nameIOR); + return true ; +} + + + +//======================================================================= +// function : IsConstructiveElement() 1/2 +// purpose : Return true if 'aLabel' is a constructive element +//======================================================================= +Standard_Boolean GEOMDS_Commands::IsConstructiveElement(const TDF_Label& aLabel) +{ + Handle(TDataStd_Integer) anAttType ; + if( aLabel.FindAttribute(TDataStd_Integer::GetID(), anAttType ) ) + return true ; + return false; +} + + +//======================================================================= +// function : IsConstructiveElement() 2/2 +// purpose : Return true if 'aLabel' is a constructive element and return the +// : topology ' returnTopo' and type 'returnType' +//======================================================================= +Standard_Boolean GEOMDS_Commands::IsConstructiveElement(const TDF_Label& aLabel, + TopoDS_Shape& returnTopo, + GEOMDS_ConstructiveType& returnType) +{ + Handle(TDataStd_Integer) anAttType ; + Handle(TNaming_NamedShape) anAttTopo ; + + if( aLabel.FindAttribute(TDataStd_Integer::GetID(), anAttType) && aLabel.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo)) { + + returnTopo = TNaming_Tool::GetShape(anAttTopo) ; + returnType = GEOMDS_ConstructiveType( anAttType->Get() ) ; + return true ; + } + return false; +} + + +//======================================================================= +// function : GetShape() +// purpose : return true and 'returnTopo' if a topology is found on 'aLabel' +//======================================================================= +Standard_Boolean GEOMDS_Commands::GetShape(const TDF_Label& aLabel, + TopoDS_Shape& returnTopo) +{ + Handle(TNaming_NamedShape) anAttTopo ; + if( aLabel.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo)) { + returnTopo = TNaming_Tool::GetShape(anAttTopo) ; + return true ; + } + return false; +} + + +//======================================================================= +// function : IsDependentShape() +// purpose : return true if the shape in the label is dependant (a sub shape) +//======================================================================= +Standard_Boolean GEOMDS_Commands::IsDependentShape(const TDF_Label& aLabel) +{ + Handle(TDF_Reference) anAttRef ; + if( aLabel.FindAttribute(TDF_Reference::GetID(), anAttRef)) + return true ; + return false; +} + + + +//======================================================================= +// function : GetMainShapeLabel() +// purpose : return true if an attribute Reference is found for 'aLabel' +// : so 'returnMainLabel' is defined. 'aLabel' is supposed to be +// : a dependent object, otherwise return false. +//======================================================================= +Standard_Boolean GEOMDS_Commands::GetMainShapeLabel(const TDF_Label& aLabel, + TDF_Label& returnMainLabel) +{ + Handle(TDF_Reference) anAttRef ; + if( aLabel.FindAttribute(TDF_Reference::GetID(), anAttRef)) { + returnMainLabel = anAttRef->Get() ; + return true ; + } + return false; +} + + +//======================================================================= +// function : ClearAllIOR() +// purpose : Clear all IOR from aLabel usually the main label. +// : Useful before reconstruction after a load of a document. +// : IOR is the attribute often called 'name' or 'nameIOR' +//======================================================================= +Standard_Boolean GEOMDS_Commands::ClearAllIOR(const TDF_Label& aLabel) +{ + TDF_ChildIterator it; + Handle(TDataStd_Name) anAttName ; + bool notTested = false ; + for( it.Initialize(aLabel, Standard_False); it.More(); it.Next() ) { + TDF_Label L = it.Value() ; + if( L.FindAttribute(TDataStd_Name::GetID(), anAttName) ) { + notTested = L.ForgetAttribute(TDataStd_Name::GetID()) ; + } + if(notTested) + MESSAGE("in GEOMDS_Commands::ClearAllIOR : IOR CLEARED" ) + } + return true ; +} + + +//======================================================================= +// function : HasIOR() +// purpose : Return true is 'aLabel' has an attribute IOR (nameIOR) +//======================================================================= +Standard_Boolean GEOMDS_Commands::HasIOR(const TDF_Label& aLabel) +{ + Handle(TDataStd_Name) anAttName ; + if( !aLabel.FindAttribute(TDataStd_Name::GetID(), anAttName) ) + return false ; + return true ; +} + +//======================================================================= +// function : ReturnNameIOR() +// purpose : Return true is 'aLabel' has an attribute IOR (nameIOR) +// : and define 'returnNameIOR' +//======================================================================= +Standard_Boolean GEOMDS_Commands::ReturnNameIOR(const TDF_Label& aLabel, + TCollection_ExtendedString& returnNameIOR) +{ + Handle(TDataStd_Name) anAttName ; + if( !aLabel.FindAttribute(TDataStd_Name::GetID(), anAttName) ) + return false ; + else { + returnNameIOR = anAttName->Get() ; + return true ; + } +} diff --git a/src/GEOMDS/GEOMDS_Commands.hxx b/src/GEOMDS/GEOMDS_Commands.hxx new file mode 100644 index 000000000..7f9195eea --- /dev/null +++ b/src/GEOMDS/GEOMDS_Commands.hxx @@ -0,0 +1,131 @@ +// File : GeomDS_Commands.hxx +// Created : +// Author : Yves FRICAUD/Lucien PIGNOLONI +// Project : SALOME +// Module : GEOM +// Copyright : OPEN CASCADE +// $Header$ + + +#ifndef _GEOMDS_Commands_HeaderFile +#define _GEOMDS_Commands_HeaderFile + +#ifndef _TDF_Label_HeaderFile +#include +#endif +class TDF_Label; +class TopoDS_Shape; +class TCollection_ExtendedString; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + + + +//============================================================================ +// class : GEOMDS_Commands +// purpose : +//============================================================================ +class GEOMDS_Commands { + +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 + // + + // used for specific entities + enum GEOMDS_ConstructiveType { VECTOR, LINE, PLANE } ; + + // Methods to add or create items in the data structure + Standard_EXPORT GEOMDS_Commands(const TDF_Label& Main); + Standard_EXPORT TDF_Label AddShape(const TopoDS_Shape& S, + const TCollection_ExtendedString& Name) ; + + Standard_EXPORT TDF_Label Generated(const TopoDS_Shape& S, + const TCollection_ExtendedString& Name) ; + Standard_EXPORT TDF_Label Generated(const TopoDS_Shape& S1, + const TopoDS_Shape& S2, + const TCollection_ExtendedString& Name) ; + + /* Shapes construction */ + Standard_EXPORT TDF_Label AddIndependentShape(const TopoDS_Shape& S, + const TCollection_AsciiString& nameIOR) ; + Standard_EXPORT TDF_Label AddDependentShape(const TopoDS_Shape& S, + const TCollection_AsciiString& nameIOR, + const TDF_Label& mainLab) ; + Standard_EXPORT TDF_Label AddConstructiveElement(const TopoDS_Shape& S, + const TCollection_ExtendedString& nameIOR, + const GEOMDS_ConstructiveType& aType); + + Standard_EXPORT Standard_Boolean AddIORNameAttribute(const TDF_Label& aLabel, + const TCollection_ExtendedString& nameIOR) ; + + /* Shapes query */ + + Standard_EXPORT Standard_Boolean IsConstructiveElement(const TDF_Label& aLabel) ; + + Standard_EXPORT Standard_Boolean IsConstructiveElement(const TDF_Label& aLabel, + TopoDS_Shape& returnTopo, + GEOMDS_ConstructiveType& returnType) ; + + Standard_EXPORT Standard_Boolean GetShape(const TDF_Label& aLabel, + TopoDS_Shape& returnTopo) ; + + Standard_EXPORT Standard_Boolean IsDependentShape(const TDF_Label& aLabel) ; + + Standard_EXPORT Standard_Boolean GetMainShapeLabel(const TDF_Label& aLabel, + TDF_Label& returnMainLabel) ; + + Standard_EXPORT Standard_Boolean ClearAllIOR(const TDF_Label& aLabel) ; + + Standard_EXPORT Standard_Boolean HasIOR(const TDF_Label& aLabel) ; + + Standard_EXPORT Standard_Boolean ReturnNameIOR(const TDF_Label& aLabel, + TCollection_ExtendedString& returnNameIOR) ; + +protected: + + // Methods PROTECTED + // + + // Fields PROTECTED + // + +private: + + // Methods PRIVATE + // + + // Fields PRIVATE + // + + TDF_Label myLab; + +}; + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMDS/GEOMDS_Commands.ixx b/src/GEOMDS/GEOMDS_Commands.ixx new file mode 100644 index 000000000..ab6173817 --- /dev/null +++ b/src/GEOMDS/GEOMDS_Commands.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOMDS_Commands.jxx" + + + + diff --git a/src/GEOMDS/GEOMDS_Commands.jxx b/src/GEOMDS/GEOMDS_Commands.jxx new file mode 100644 index 000000000..9dec188c7 --- /dev/null +++ b/src/GEOMDS/GEOMDS_Commands.jxx @@ -0,0 +1,12 @@ +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _GEOMDS_Commands_HeaderFile +#include "GEOMDS_Commands.hxx" +#endif \ No newline at end of file diff --git a/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx b/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx new file mode 100644 index 000000000..edda47899 --- /dev/null +++ b/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx @@ -0,0 +1,106 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile +#define _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile + +#ifndef _TCollection_BasicMapIterator_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_Standard_Transient_HeaderFile +#include +#endif +#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile +#include "Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" +#endif +class Standard_NoSuchObject; +class Standard_Transient; +class TColStd_MapIntegerHasher; +class GEOMDS_DataMapOfIntegerTransient; +class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient : public TCollection_BasicMapIterator { + +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 GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient(); +Standard_EXPORT GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient(const GEOMDS_DataMapOfIntegerTransient& aMap); +Standard_EXPORT void Initialize(const GEOMDS_DataMapOfIntegerTransient& aMap) ; +Standard_EXPORT const Standard_Integer& Key() const; +Standard_EXPORT const Handle_Standard_Transient& Value() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx b/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx new file mode 100644 index 000000000..65172b2c9 --- /dev/null +++ b/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx @@ -0,0 +1,50 @@ +using namespace std; +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx" + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _Standard_Transient_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _GEOMDS_DataMapOfIntegerTransient_HeaderFile +#include "GEOMDS_DataMapOfIntegerTransient.hxx" +#endif +#ifndef _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile +#include "GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" +#endif + + +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem Handle_Standard_Transient +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient +#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_() +#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx b/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx new file mode 100644 index 000000000..0b385827b --- /dev/null +++ b/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx @@ -0,0 +1,141 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile +#define _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile +#include "Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" +#endif + +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_Standard_Transient_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class Standard_Transient; +class TColStd_MapIntegerHasher; +class GEOMDS_DataMapOfIntegerTransient; +class GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient; + + +class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient : public TCollection_MapNode { + +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 inline GEOMDS_DataMapNodeOfDataMapOfIntegerTransient(const Standard_Integer& K,const Handle(Standard_Transient)& I,const TCollection_MapNodePtr& n); +Standard_EXPORT inline Standard_Integer& Key() const; +Standard_EXPORT inline Handle_Standard_Transient& Value() const; +Standard_EXPORT ~GEOMDS_DataMapNodeOfDataMapOfIntegerTransient(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_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_Integer myKey; +Handle_Standard_Transient myValue; + + +}; + +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem Handle_Standard_Transient +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient +#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_() +#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient +#define TCollection_DataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_DataMapNode +#undef TCollection_DataMapNode_hxx +#undef TCollection_DataMapIterator +#undef TCollection_DataMapIterator_hxx +#undef Handle_TCollection_DataMapNode +#undef TCollection_DataMapNode_Type_ +#undef TCollection_DataMap +#undef TCollection_DataMap_hxx + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx b/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx new file mode 100644 index 000000000..75d4861a7 --- /dev/null +++ b/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx @@ -0,0 +1,99 @@ +using namespace std; +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_Transient_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _GEOMDS_DataMapOfIntegerTransient_HeaderFile +#include "GEOMDS_DataMapOfIntegerTransient.hxx" +#endif +#ifndef _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile +#include "GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx" +#endif +GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::~GEOMDS_DataMapNodeOfDataMapOfIntegerTransient() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + 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("GEOMDS_DataMapNodeOfDataMapOfIntegerTransient", + sizeof(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient))) { + _anOtherObject = Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)((Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::DynamicType() const +{ + return STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) ; +} +Standard_Boolean GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::~Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient() {} +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem Handle_Standard_Transient +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient +#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_() +#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient.hxx b/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient.hxx new file mode 100644 index 000000000..5c8acc5a9 --- /dev/null +++ b/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient.hxx @@ -0,0 +1,128 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _GEOMDS_DataMapOfIntegerTransient_HeaderFile +#define _GEOMDS_DataMapOfIntegerTransient_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_Standard_Transient_HeaderFile +#include +#endif +#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile +#include "Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_NoSuchObject; +class Standard_Transient; +class TColStd_MapIntegerHasher; +class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient; +class GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMDS_DataMapOfIntegerTransient : public TCollection_BasicMap { + +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 GEOMDS_DataMapOfIntegerTransient(const Standard_Integer NbBuckets = 1); +Standard_EXPORT GEOMDS_DataMapOfIntegerTransient& Assign(const GEOMDS_DataMapOfIntegerTransient& Other) ; +GEOMDS_DataMapOfIntegerTransient& operator =(const GEOMDS_DataMapOfIntegerTransient& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~GEOMDS_DataMapOfIntegerTransient() +{ + Clear(); +} + +Standard_EXPORT Standard_Boolean Bind(const Standard_Integer& K,const Handle(Standard_Transient)& I) ; +Standard_EXPORT Standard_Boolean IsBound(const Standard_Integer& K) const; +Standard_EXPORT Standard_Boolean UnBind(const Standard_Integer& K) ; +Standard_EXPORT const Handle_Standard_Transient& Find(const Standard_Integer& K) const; + const Handle_Standard_Transient& operator()(const Standard_Integer& K) const +{ + return Find(K); +} + +Standard_EXPORT Handle_Standard_Transient& ChangeFind(const Standard_Integer& K) ; + Handle_Standard_Transient& operator()(const Standard_Integer& K) +{ + return ChangeFind(K); +} + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + Standard_EXPORT GEOMDS_DataMapOfIntegerTransient(const GEOMDS_DataMapOfIntegerTransient& Other); + + +// Fields PRIVATE +// + + +}; + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient_0.cxx b/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient_0.cxx new file mode 100644 index 000000000..acbe19cd0 --- /dev/null +++ b/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient_0.cxx @@ -0,0 +1,53 @@ +using namespace std; +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOMDS_DataMapOfIntegerTransient.hxx" + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _Standard_Transient_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile +#include "GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" +#endif +#ifndef _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile +#include "GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx" +#endif + + +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem Handle_Standard_Transient +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient +#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_() +#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOMDS/GEOMDS_Explorer.cdl b/src/GEOMDS/GEOMDS_Explorer.cdl new file mode 100644 index 000000000..65a023727 --- /dev/null +++ b/src/GEOMDS/GEOMDS_Explorer.cdl @@ -0,0 +1,33 @@ +// File : GEOMDS_Explorer.cdl +// Created : +// Author : Yves FRICAUD +// Project : SALOME +// Module : GEOM +// Copyright : OPEN CASCADE +// $Header$ + +class Explorer from GEOMDS + + ---Purpose: + +uses + ChildIterator from TDF, + Label from TDF, + ExtendedString from TCollection, + Shape from TopoDS + + +is + Create ( Main : Label from TDF) returns Explorer from GEOMDS; + + More(me : in out) returns Boolean from Standard; + + Next(me : in out); + + Shape(me)returns Shape from TopoDS; + + Name(me) returns ExtendedString from TCollection; + +fields + myChildIterator : ChildIterator from TDF; +end Explorer; diff --git a/src/GEOMDS/GEOMDS_Explorer.cxx b/src/GEOMDS/GEOMDS_Explorer.cxx new file mode 100644 index 000000000..5e4b2bcf6 --- /dev/null +++ b/src/GEOMDS/GEOMDS_Explorer.cxx @@ -0,0 +1,107 @@ +using namespace std; +// File : GEOMDS_Explorer.cxx +// Created : +// Author : Yves FRICAUD +// Project : SALOME +// Module : GEOM +// Copyright : OPEN CASCADE +// $Header$ + + +#include "GEOMDS_Explorer.ixx" + +#include +#include +#include + + +//======================================================================= +//function : GEOMDS_Explorer +//purpose : +//======================================================================= + +GEOMDS_Explorer::GEOMDS_Explorer(const TDF_Label& Main) : myChildIterator(Main) +{ +} + + +//======================================================================= +//function : const; +//purpose : +//======================================================================= + +Standard_Boolean GEOMDS_Explorer::More() +{ + if (!myChildIterator.More()) + return 0; + Handle(TDataStd_Name) Att; + Handle(TNaming_NamedShape) NS; + TDF_Label L = myChildIterator.Value(); + if (( L.FindAttribute(TDataStd_Name::GetID(),Att) ) || + (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) + ) + return 1; + // myChildIterator.Next(); + // More(); + return 0; + /* + if (!myChildIterator.More()) + return 0; + TDF_Label L = myChildIterator.Value(); + Handle(TNaming_NamedShape) NS; + for (TDF_ChildIterator it2(L); it2.More(); it2.Next()) { + TDF_Label L2 = it2.Value(); + if (L2.FindAttribute(TNaming_NamedShape::GetID(),NS)) { + return 1; + } + myChildIterator.Next(); + } + return 0; + */ +} + + +//======================================================================= +//function : Next +//purpose : +//======================================================================= + +void GEOMDS_Explorer::Next() +{ + myChildIterator.Next(); +} + + +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + +TopoDS_Shape GEOMDS_Explorer::Shape() const +{ + Handle(TNaming_NamedShape) NS; + TDF_Label L = myChildIterator.Value(); + L.FindAttribute(TNaming_NamedShape::GetID(),NS); + TopoDS_Shape S = TNaming_Tool::GetShape(NS); + return S; +} + +//======================================================================= +//function : Name +//purpose : +//======================================================================= + +TCollection_ExtendedString GEOMDS_Explorer::Name() const +{ + TDF_Label L = myChildIterator.Value(); + Handle(TDataStd_Name) Att; + if ( L.FindAttribute(TDataStd_Name::GetID(),Att) ) + //L.FindAttribute(TDataStd_Name::GetID(),Att); + return Att->Get(); + else + return TCollection_ExtendedString(); +} + + + + diff --git a/src/GEOMDS/GEOMDS_Explorer.hxx b/src/GEOMDS/GEOMDS_Explorer.hxx new file mode 100644 index 000000000..c8858f460 --- /dev/null +++ b/src/GEOMDS/GEOMDS_Explorer.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _GEOMDS_Explorer_HeaderFile +#define _GEOMDS_Explorer_HeaderFile + +#ifndef _TDF_ChildIterator_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class TDF_Label; +class TopoDS_Shape; +class TCollection_ExtendedString; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMDS_Explorer { + +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 GEOMDS_Explorer(const TDF_Label& Main); +Standard_EXPORT Standard_Boolean More() ; +Standard_EXPORT void Next() ; +Standard_EXPORT TopoDS_Shape Shape() const; +Standard_EXPORT TCollection_ExtendedString Name() const; + +protected: + + // Methods PROTECTED + // + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + // Fields PRIVATE + // +TDF_ChildIterator myChildIterator; + + +}; + + +// other inline functions and methods (like "C++: function call" methods) +// + +#endif diff --git a/src/GEOMDS/GEOMDS_Explorer.ixx b/src/GEOMDS/GEOMDS_Explorer.ixx new file mode 100644 index 000000000..795b49dbd --- /dev/null +++ b/src/GEOMDS/GEOMDS_Explorer.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOMDS_Explorer.jxx" + + + + diff --git a/src/GEOMDS/GEOMDS_Explorer.jxx b/src/GEOMDS/GEOMDS_Explorer.jxx new file mode 100644 index 000000000..3e477e7b9 --- /dev/null +++ b/src/GEOMDS/GEOMDS_Explorer.jxx @@ -0,0 +1,12 @@ +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _GEOMDS_Explorer_HeaderFile +#include "GEOMDS_Explorer.hxx" +#endif diff --git a/src/GEOMDS/Handle_GEOMDS_Application.hxx b/src/GEOMDS/Handle_GEOMDS_Application.hxx new file mode 100644 index 000000000..ba3b1a272 --- /dev/null +++ b/src/GEOMDS/Handle_GEOMDS_Application.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_GEOMDS_Application_HeaderFile +#define _Handle_GEOMDS_Application_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDocStd_Application_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDocStd_Application); +class GEOMDS_Application; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SimpleOCAF_Application); + +class Handle(GEOMDS_Application) : public Handle(TDocStd_Application) { + 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(GEOMDS_Application)():Handle(TDocStd_Application)() {} + Handle(GEOMDS_Application)(const Handle(GEOMDS_Application)& aHandle) : Handle(TDocStd_Application)(aHandle) + { + } + + Handle(GEOMDS_Application)(const GEOMDS_Application* anItem) : Handle(TDocStd_Application)((TDocStd_Application *)anItem) + { + } + + Handle(GEOMDS_Application)& operator=(const Handle(GEOMDS_Application)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMDS_Application)& operator=(const GEOMDS_Application* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMDS_Application* operator->() + { + return (GEOMDS_Application *)ControlAccess(); + } + + GEOMDS_Application* operator->() const + { + return (GEOMDS_Application *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMDS_Application)(); + + Standard_EXPORT static const Handle(GEOMDS_Application) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMDS/Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx b/src/GEOMDS/Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx new file mode 100644 index 000000000..250fc7d28 --- /dev/null +++ b/src/GEOMDS/Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile +#define _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient); + +class Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) : public Handle(TCollection_MapNode) { + 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(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)():Handle(TCollection_MapNode)() {} + Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)(const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)(const GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& operator=(const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& operator=(const GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* operator->() + { + return (GEOMDS_DataMapNodeOfDataMapOfIntegerTransient *)ControlAccess(); + } + + GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* operator->() const + { + return (GEOMDS_DataMapNodeOfDataMapOfIntegerTransient *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)(); + + Standard_EXPORT static const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMDS/Makefile.in b/src/GEOMDS/Makefile.in new file mode 100644 index 000000000..095106538 --- /dev/null +++ b/src/GEOMDS/Makefile.in @@ -0,0 +1,54 @@ +# -* Makefile *- +# +# Author : Patrick GOLDBRONN (CEA) +# Date : 29/06/2001 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:$(srcdir):$(top_srcdir)/idl:$(top_builddir)/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libGeometryDS.la +LIB_SRC = GEOMDS_Application.cxx \ + GEOMDS_Commands.cxx \ + GEOMDS_Explorer.cxx \ + GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx \ + GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx \ + GEOMDS_DataMapOfIntegerTransient_0.cxx +LIB_CLIENT_IDL = +LIB_SERVER_IDL = + +# Executables targets +BIN = +BIN_SRC = +BIN_CLIENT_IDL = +BIN_SERVER_IDL = + +# header files +EXPORT_HEADERS= GEOMDS_Application.hxx \ + GEOMDS_DataMapOfIntegerTransient.hxx \ + Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx \ + Handle_GEOMDS_Application.hxx \ + GEOMDS_Commands.hxx \ + GEOMDS_Explorer.hxx + +# additionnal information to compil and link file +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += $(OCC_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +# additional file to be cleaned +MOSTLYCLEAN = +CLEAN = +DISTCLEAN = + +@CONCLUDE@ + diff --git a/src/GEOMFiltersSelection/GEOM_EdgeFilter.cxx b/src/GEOMFiltersSelection/GEOM_EdgeFilter.cxx new file mode 100644 index 000000000..5142a6db8 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_EdgeFilter.cxx @@ -0,0 +1,114 @@ +using namespace std; +// File : GEOM_EdgeFilter.cxx +// Created : Fri Dec 07 09:57:24 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE +// $Header$ + +#include "GEOM_EdgeFilter.ixx" +#include "GEOM_Client.hxx" + +#include "SALOME_InteractiveObject.hxx" +#include "GEOM_InteractiveObject.hxx" +#include "GEOM_ShapeTypeFilter.hxx" +#include "SALOME_TypeFilter.hxx" + +#include "utilities.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" + +// Open CASCADE Includes +#include +#include +#include +#include + + +static GEOM_Client ShapeReader; + + +/*! + enumeration TypeOfEdge is AnyEdge,Line,Circle; +*/ +GEOM_EdgeFilter::GEOM_EdgeFilter(const StdSelect_TypeOfEdge Edge, + GEOM::GEOM_Gen_ptr geom) +{ + myKind = Edge; + myComponentGeom = GEOM::GEOM_Gen::_narrow(geom); +} + +Standard_Boolean GEOM_EdgeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +{ + Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" ); + if ( !GeomFilter->IsOk(anObj) ) + return false; + + Handle(GEOM_ShapeTypeFilter) GeomShapeTypeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myComponentGeom ); + if ( !GeomShapeTypeFilter->IsOk(anObj) ) + return false; + + if ( anObj->hasEntry() ) { + QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() ); + if ( aShape->_is_nil() ) + return false; + + TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); + if ( Shape.IsNull() ) + return false; + + switch (myKind) { + case StdSelect_AnyEdge: + return Standard_True; + case StdSelect_Line: + { + BRepAdaptor_Curve curv(TopoDS::Edge(Shape)); + return (curv.GetType() == GeomAbs_Line); + } + break; + case StdSelect_Circle: + BRepAdaptor_Curve curv(TopoDS::Edge(Shape)); + return (curv.GetType() == GeomAbs_Circle); + } + } + } + } + + if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + Handle(GEOM_InteractiveObject) GObject = + Handle(GEOM_InteractiveObject)::DownCast(anObj); + + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() ); + if ( aShape->_is_nil() ) + return false; + + TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); + if ( Shape.IsNull() ) + return false; + + switch (myKind) { + case StdSelect_AnyEdge: + return Standard_True; + case StdSelect_Line: + { + BRepAdaptor_Curve curv(TopoDS::Edge(Shape)); + return (curv.GetType() == GeomAbs_Line); + } + break; + case StdSelect_Circle: + BRepAdaptor_Curve curv(TopoDS::Edge(Shape)); + return (curv.GetType() == GeomAbs_Circle); + } + } + return false; +} diff --git a/src/GEOMFiltersSelection/GEOM_EdgeFilter.hxx b/src/GEOMFiltersSelection/GEOM_EdgeFilter.hxx new file mode 100644 index 000000000..153a6e58f --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_EdgeFilter.hxx @@ -0,0 +1,106 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _GEOM_EdgeFilter_HeaderFile +#define _GEOM_EdgeFilter_HeaderFile + +#ifndef _Handle_GEOM_EdgeFilter_HeaderFile +#include "Handle_GEOM_EdgeFilter.hxx" +#endif + +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_Filter.hxx" + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +// Open CASCADE Includes +#include +#include +#include +#include + +class GEOM_EdgeFilter : public SALOME_Filter { + +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_EdgeFilter(const StdSelect_TypeOfEdge Edge, + GEOM::GEOM_Gen_ptr geom); + +Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; +Standard_EXPORT ~GEOM_EdgeFilter(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOM_EdgeFilter_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +StdSelect_TypeOfEdge myKind; +GEOM::GEOM_Gen_var myComponentGeom; + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMFiltersSelection/GEOM_EdgeFilter.ixx b/src/GEOMFiltersSelection/GEOM_EdgeFilter.ixx new file mode 100644 index 000000000..a36de41da --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_EdgeFilter.ixx @@ -0,0 +1,71 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOM_EdgeFilter.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +GEOM_EdgeFilter::~GEOM_EdgeFilter() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOM_EdgeFilter_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter); + 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_EdgeFilter", + sizeof(GEOM_EdgeFilter), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOM_EdgeFilter) Handle(GEOM_EdgeFilter)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOM_EdgeFilter) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOM_EdgeFilter))) { + _anOtherObject = Handle(GEOM_EdgeFilter)((Handle(GEOM_EdgeFilter)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOM_EdgeFilter::DynamicType() const +{ + return STANDARD_TYPE(GEOM_EdgeFilter) ; +} +Standard_Boolean GEOM_EdgeFilter::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOM_EdgeFilter) == AType || SALOME_Filter::IsKind(AType)); +} +Handle_GEOM_EdgeFilter::~Handle_GEOM_EdgeFilter() {} + diff --git a/src/GEOMFiltersSelection/GEOM_EdgeFilter.jxx b/src/GEOMFiltersSelection/GEOM_EdgeFilter.jxx new file mode 100644 index 000000000..d080c8e56 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_EdgeFilter.jxx @@ -0,0 +1,3 @@ +#ifndef _GEOM_EdgeFilter_HeaderFile +#include "GEOM_EdgeFilter.hxx" +#endif diff --git a/src/GEOMFiltersSelection/GEOM_FaceFilter.cxx b/src/GEOMFiltersSelection/GEOM_FaceFilter.cxx new file mode 100644 index 000000000..aefda178f --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_FaceFilter.cxx @@ -0,0 +1,164 @@ +using namespace std; +// File : GEOM_FaceFilter.cxx +// Created : Fri Dec 07 09:57:24 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE +// $Header$ + +#include "GEOM_FaceFilter.ixx" +#include "GEOM_Client.hxx" + +#include "SALOME_InteractiveObject.hxx" +#include "GEOM_InteractiveObject.hxx" +#include "GEOM_ShapeTypeFilter.hxx" +#include "SALOME_TypeFilter.hxx" + +#include "utilities.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" + +// Open CASCADE Includes +#include +#include +#include +#include +#include + + +static GEOM_Client ShapeReader; + +/*! + enumeration TypeOfFace is AnyFace,Plane,Cylinder,Sphere,Torus,Revol,Cone; +*/ +GEOM_FaceFilter::GEOM_FaceFilter(const StdSelect_TypeOfFace Face, + GEOM::GEOM_Gen_ptr geom) +{ + myKind = Face; + myComponentGeom = GEOM::GEOM_Gen::_narrow(geom); +} + +Standard_Boolean GEOM_FaceFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +{ + Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" ); + if ( !GeomFilter->IsOk(anObj) ) + return false; + + Handle(GEOM_ShapeTypeFilter) GeomShapeTypeFilter = new GEOM_ShapeTypeFilter( TopAbs_FACE, myComponentGeom ); + if ( !GeomShapeTypeFilter->IsOk(anObj) ) + return false; + + if ( anObj->hasEntry() ) { + QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() ); + if ( aShape->_is_nil() ) + return false; + + TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); + if ( Shape.IsNull() ) + return false; + + switch (myKind) { + case StdSelect_AnyFace: + return Standard_True; + case StdSelect_Plane: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return (surf.GetType() == GeomAbs_Plane); + } + case StdSelect_Cylinder: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return (surf.GetType() == GeomAbs_Cylinder); + } + case StdSelect_Sphere: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return (surf.GetType() == GeomAbs_Sphere); + } + case StdSelect_Torus: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return ( surf.GetType() == GeomAbs_Torus); + } + case StdSelect_Revol: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return ( surf.GetType() == GeomAbs_Cylinder || + surf.GetType() == GeomAbs_Cone || + surf.GetType() == GeomAbs_Torus || + surf.GetType() == GeomAbs_Sphere || + surf.GetType() == GeomAbs_SurfaceOfRevolution ); + } + case StdSelect_Cone: // en attendant la liberation du cdl, on l'utilise pour Cone + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return (surf.GetType() == GeomAbs_Cone); + } + } + } + } + } + + if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + Handle(GEOM_InteractiveObject) GObject = + Handle(GEOM_InteractiveObject)::DownCast(anObj); + + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() ); + if ( aShape->_is_nil() ) + return false; + + TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); + if ( Shape.IsNull() ) + return false; + + switch (myKind) { + case StdSelect_AnyFace: + return Standard_True; + case StdSelect_Plane: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return (surf.GetType() == GeomAbs_Plane); + } + case StdSelect_Cylinder: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return (surf.GetType() == GeomAbs_Cylinder); + } + case StdSelect_Sphere: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return (surf.GetType() == GeomAbs_Sphere); + } + case StdSelect_Torus: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return ( surf.GetType() == GeomAbs_Torus); + } + case StdSelect_Revol: + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return ( surf.GetType() == GeomAbs_Cylinder || + surf.GetType() == GeomAbs_Cone || + surf.GetType() == GeomAbs_Torus || + surf.GetType() == GeomAbs_Sphere || + surf.GetType() == GeomAbs_SurfaceOfRevolution ); + } + case StdSelect_Cone: // en attendant la liberation du cdl, on l'utilise pour Cone + { + BRepAdaptor_Surface surf(TopoDS::Face(Shape)); + return (surf.GetType() == GeomAbs_Cone); + } + } + } + return false; +} diff --git a/src/GEOMFiltersSelection/GEOM_FaceFilter.hxx b/src/GEOMFiltersSelection/GEOM_FaceFilter.hxx new file mode 100644 index 000000000..4f8a5ae49 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_FaceFilter.hxx @@ -0,0 +1,106 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _GEOM_FaceFilter_HeaderFile +#define _GEOM_FaceFilter_HeaderFile + +#ifndef _Handle_GEOM_FaceFilter_HeaderFile +#include "Handle_GEOM_FaceFilter.hxx" +#endif + +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_Filter.hxx" + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +// Open CASCADE Includes +#include +#include +#include +#include + +class GEOM_FaceFilter : public SALOME_Filter { + +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_FaceFilter(const StdSelect_TypeOfFace Face, + GEOM::GEOM_Gen_ptr geom); + +Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; +Standard_EXPORT ~GEOM_FaceFilter(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOM_FaceFilter_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +StdSelect_TypeOfFace myKind; +GEOM::GEOM_Gen_var myComponentGeom; + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMFiltersSelection/GEOM_FaceFilter.ixx b/src/GEOMFiltersSelection/GEOM_FaceFilter.ixx new file mode 100644 index 000000000..436a1b173 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_FaceFilter.ixx @@ -0,0 +1,71 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOM_FaceFilter.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +GEOM_FaceFilter::~GEOM_FaceFilter() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOM_FaceFilter_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter); + 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_FaceFilter", + sizeof(GEOM_FaceFilter), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOM_FaceFilter) Handle(GEOM_FaceFilter)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOM_FaceFilter) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOM_FaceFilter))) { + _anOtherObject = Handle(GEOM_FaceFilter)((Handle(GEOM_FaceFilter)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOM_FaceFilter::DynamicType() const +{ + return STANDARD_TYPE(GEOM_FaceFilter) ; +} +Standard_Boolean GEOM_FaceFilter::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOM_FaceFilter) == AType || SALOME_Filter::IsKind(AType)); +} +Handle_GEOM_FaceFilter::~Handle_GEOM_FaceFilter() {} + diff --git a/src/GEOMFiltersSelection/GEOM_FaceFilter.jxx b/src/GEOMFiltersSelection/GEOM_FaceFilter.jxx new file mode 100644 index 000000000..521f074c3 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_FaceFilter.jxx @@ -0,0 +1,3 @@ +#ifndef _GEOM_FaceFilter_HeaderFile +#include "GEOM_FaceFilter.hxx" +#endif diff --git a/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.cxx b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.cxx new file mode 100644 index 000000000..519d1037f --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.cxx @@ -0,0 +1,89 @@ +using namespace std; +// File : GEOM_ShapeTypeFilter.cxx +// Created : Fri Dec 07 09:57:24 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "GEOM_ShapeTypeFilter.ixx" +#include "GEOM_Client.hxx" + +#include "SALOME_InteractiveObject.hxx" +#include "GEOM_InteractiveObject.hxx" +#include "SALOME_TypeFilter.hxx" + +#include "utilities.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" + +static GEOM_Client ShapeReader; + +GEOM_ShapeTypeFilter::GEOM_ShapeTypeFilter(TopAbs_ShapeEnum ShapeType, + GEOM::GEOM_Gen_ptr geom) +{ + myKind = ShapeType; + myComponentGeom = GEOM::GEOM_Gen::_narrow(geom); +} + +Standard_Boolean GEOM_ShapeTypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +{ + Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" ); + if ( !GeomFilter->IsOk(anObj) ) + return false; + if ( anObj->hasEntry() ) { + QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() ); + if ( aShape->_is_nil() ) + return false; + + TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); + if ( Shape.IsNull() ) + return false; + + MESSAGE ( " myKind = " << myKind ); + MESSAGE ( " Shape.ShapeType = " << Shape.ShapeType() ); + if ( myKind == TopAbs_SHAPE ) + return true; + + if ( Shape.ShapeType() == myKind ) + return true; + else + return false; + } + } + } + + if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + Handle(GEOM_InteractiveObject) GObject = + Handle(GEOM_InteractiveObject)::DownCast(anObj); + + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() ); + if ( aShape->_is_nil() ) + return false; + + TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); + if ( Shape.IsNull() ) + return false; + + MESSAGE ( " myKind = " << myKind ); + MESSAGE ( " Shape.ShapeType = " << Shape.ShapeType() ); + if ( myKind == TopAbs_SHAPE ) + return true; + + if ( Shape.ShapeType() == myKind ) + return true; + else + return false; + } + return false; +} diff --git a/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.hxx b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.hxx new file mode 100644 index 000000000..4c62f026d --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.hxx @@ -0,0 +1,104 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _GEOM_ShapeTypeFilter_HeaderFile +#define _GEOM_ShapeTypeFilter_HeaderFile + +#ifndef _Handle_GEOM_ShapeTypeFilter_HeaderFile +#include "Handle_GEOM_ShapeTypeFilter.hxx" +#endif + +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_Filter.hxx" + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +// Open CASCADE Includes +#include +#include +#include + +class GEOM_ShapeTypeFilter : public SALOME_Filter { + +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_ShapeTypeFilter(TopAbs_ShapeEnum ShapeType, + GEOM::GEOM_Gen_ptr geom); +Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; +Standard_EXPORT ~GEOM_ShapeTypeFilter(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOM_ShapeTypeFilter_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +TopAbs_ShapeEnum myKind; +GEOM::GEOM_Gen_var myComponentGeom; + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.ixx b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.ixx new file mode 100644 index 000000000..ee6e4a994 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.ixx @@ -0,0 +1,71 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOM_ShapeTypeFilter.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +GEOM_ShapeTypeFilter::~GEOM_ShapeTypeFilter() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOM_ShapeTypeFilter_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter); + 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_ShapeTypeFilter", + sizeof(GEOM_ShapeTypeFilter), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOM_ShapeTypeFilter) Handle(GEOM_ShapeTypeFilter)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOM_ShapeTypeFilter) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOM_ShapeTypeFilter))) { + _anOtherObject = Handle(GEOM_ShapeTypeFilter)((Handle(GEOM_ShapeTypeFilter)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOM_ShapeTypeFilter::DynamicType() const +{ + return STANDARD_TYPE(GEOM_ShapeTypeFilter) ; +} +Standard_Boolean GEOM_ShapeTypeFilter::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOM_ShapeTypeFilter) == AType || SALOME_Filter::IsKind(AType)); +} +Handle_GEOM_ShapeTypeFilter::~Handle_GEOM_ShapeTypeFilter() {} + diff --git a/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.jxx b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.jxx new file mode 100644 index 000000000..be7dac640 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.jxx @@ -0,0 +1,3 @@ +#ifndef _GEOM_ShapeTypeFilter_HeaderFile +#include "GEOM_ShapeTypeFilter.hxx" +#endif diff --git a/src/GEOMFiltersSelection/Handle_GEOM_EdgeFilter.hxx b/src/GEOMFiltersSelection/Handle_GEOM_EdgeFilter.hxx new file mode 100644 index 000000000..6cc45e9e2 --- /dev/null +++ b/src/GEOMFiltersSelection/Handle_GEOM_EdgeFilter.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_GEOM_EdgeFilter_HeaderFile +#define _Handle_GEOM_EdgeFilter_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_Filter_HeaderFile +#include "Handle_SALOME_Filter.hxx" +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(SALOME_Filter); +class GEOM_EdgeFilter; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_EdgeFilter); + +class Handle(GEOM_EdgeFilter) : public Handle(SALOME_Filter) { + 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_EdgeFilter)():Handle(SALOME_Filter)() {} + Handle(GEOM_EdgeFilter)(const Handle(GEOM_EdgeFilter)& aHandle) : Handle(SALOME_Filter)(aHandle) + { + } + + Handle(GEOM_EdgeFilter)(const GEOM_EdgeFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem) + { + } + + Handle(GEOM_EdgeFilter)& operator=(const Handle(GEOM_EdgeFilter)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOM_EdgeFilter)& operator=(const GEOM_EdgeFilter* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOM_EdgeFilter* operator->() + { + return (GEOM_EdgeFilter *)ControlAccess(); + } + + GEOM_EdgeFilter* operator->() const + { + return (GEOM_EdgeFilter *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOM_EdgeFilter)(); + + Standard_EXPORT static const Handle(GEOM_EdgeFilter) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMFiltersSelection/Handle_GEOM_FaceFilter.hxx b/src/GEOMFiltersSelection/Handle_GEOM_FaceFilter.hxx new file mode 100644 index 000000000..9881e3e63 --- /dev/null +++ b/src/GEOMFiltersSelection/Handle_GEOM_FaceFilter.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_GEOM_FaceFilter_HeaderFile +#define _Handle_GEOM_FaceFilter_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_Filter_HeaderFile +#include "Handle_SALOME_Filter.hxx" +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(SALOME_Filter); +class GEOM_FaceFilter; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_FaceFilter); + +class Handle(GEOM_FaceFilter) : public Handle(SALOME_Filter) { + 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_FaceFilter)():Handle(SALOME_Filter)() {} + Handle(GEOM_FaceFilter)(const Handle(GEOM_FaceFilter)& aHandle) : Handle(SALOME_Filter)(aHandle) + { + } + + Handle(GEOM_FaceFilter)(const GEOM_FaceFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem) + { + } + + Handle(GEOM_FaceFilter)& operator=(const Handle(GEOM_FaceFilter)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOM_FaceFilter)& operator=(const GEOM_FaceFilter* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOM_FaceFilter* operator->() + { + return (GEOM_FaceFilter *)ControlAccess(); + } + + GEOM_FaceFilter* operator->() const + { + return (GEOM_FaceFilter *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOM_FaceFilter)(); + + Standard_EXPORT static const Handle(GEOM_FaceFilter) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMFiltersSelection/Handle_GEOM_ShapeTypeFilter.hxx b/src/GEOMFiltersSelection/Handle_GEOM_ShapeTypeFilter.hxx new file mode 100644 index 000000000..8c7cf97b9 --- /dev/null +++ b/src/GEOMFiltersSelection/Handle_GEOM_ShapeTypeFilter.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_GEOM_ShapeTypeFilter_HeaderFile +#define _Handle_GEOM_ShapeTypeFilter_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_Filter_HeaderFile +#include "Handle_SALOME_Filter.hxx" +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(SALOME_Filter); +class GEOM_ShapeTypeFilter; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_ShapeTypeFilter); + +class Handle(GEOM_ShapeTypeFilter) : public Handle(SALOME_Filter) { + 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_ShapeTypeFilter)():Handle(SALOME_Filter)() {} + Handle(GEOM_ShapeTypeFilter)(const Handle(GEOM_ShapeTypeFilter)& aHandle) : Handle(SALOME_Filter)(aHandle) + { + } + + Handle(GEOM_ShapeTypeFilter)(const GEOM_ShapeTypeFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem) + { + } + + Handle(GEOM_ShapeTypeFilter)& operator=(const Handle(GEOM_ShapeTypeFilter)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOM_ShapeTypeFilter)& operator=(const GEOM_ShapeTypeFilter* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOM_ShapeTypeFilter* operator->() + { + return (GEOM_ShapeTypeFilter *)ControlAccess(); + } + + GEOM_ShapeTypeFilter* operator->() const + { + return (GEOM_ShapeTypeFilter *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOM_ShapeTypeFilter)(); + + Standard_EXPORT static const Handle(GEOM_ShapeTypeFilter) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMFiltersSelection/Makefile.in b/src/GEOMFiltersSelection/Makefile.in new file mode 100644 index 000000000..e4b8b5ddf --- /dev/null +++ b/src/GEOMFiltersSelection/Makefile.in @@ -0,0 +1,45 @@ +# -* Makefile *- +# +# Author : Patrick GOLDBRONN (CEA) +# Date : 29/06/2001 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:$(srcdir):$(top_srcdir)/idl:$(top_builddir)/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libGeometryFiltersSelection.la +LIB_SRC = GEOM_ShapeTypeFilter.cxx \ + GEOM_FaceFilter.cxx \ + GEOM_EdgeFilter.cxx + +LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl + +# header files +EXPORT_HEADERS= GEOM_ShapeTypeFilter.hxx \ + Handle_GEOM_ShapeTypeFilter.hxx \ + GEOM_FaceFilter.hxx \ + Handle_GEOM_FaceFilter.hxx \ + GEOM_EdgeFilter.hxx \ + Handle_GEOM_EdgeFilter.hxx + +# additionnal information to compil and link file +CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) +CXXFLAGS += $(OCC_CXXFLAGS) +LDFLAGS += $(OCC_LIBS) + +# additional file to be cleaned +MOSTLYCLEAN = +CLEAN = +DISTCLEAN = + +@CONCLUDE@ + diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx new file mode 100644 index 000000000..2f4e5c59b --- /dev/null +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -0,0 +1,127 @@ +using namespace std; +// File : GEOM_AISShape.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE 2002 +// $Header$ + +/*! + \class GEOM_AISShape GEOM_AISShape.hxx + \brief .... +*/ + +#include "GEOM_AISShape.ixx" +#include "SALOME_InteractiveObject.hxx" + +#include "utilities.h" + +// Open CASCADE Includes +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +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; +} diff --git a/src/OBJECT/GEOM_AISShape.hxx b/src/OBJECT/GEOM_AISShape.hxx new file mode 100644 index 000000000..5c63ece8b --- /dev/null +++ b/src/OBJECT/GEOM_AISShape.hxx @@ -0,0 +1,125 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _GEOM_AISShape_HeaderFile +#define _GEOM_AISShape_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#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 +#endif +#ifndef _SALOME_AISShape_HeaderFile +#include "SALOME_AISShape.hxx" +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_PrsMgr_PresentationManager3d_HeaderFile +#include +#endif +#ifndef _Handle_Prs3d_Presentation_HeaderFile +#include +#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 diff --git a/src/OBJECT/GEOM_AISShape.ixx b/src/OBJECT/GEOM_AISShape.ixx new file mode 100644 index 000000000..3179d4a5a --- /dev/null +++ b/src/OBJECT/GEOM_AISShape.ixx @@ -0,0 +1,79 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOM_AISShape.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#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() {} + diff --git a/src/OBJECT/GEOM_AISShape.jxx b/src/OBJECT/GEOM_AISShape.jxx new file mode 100644 index 000000000..fa4227d8b --- /dev/null +++ b/src/OBJECT/GEOM_AISShape.jxx @@ -0,0 +1,15 @@ +#ifndef _GEOM_InteractiveObject_HeaderFile +#include "GEOM_InteractiveObject.hxx" +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _GEOM_AISShape_HeaderFile +#include "GEOM_AISShape.hxx" +#endif +#ifndef _PrsMgr_PresentationManager3d_HeaderFile +#include +#endif +#ifndef _Prs3d_Presentation_HeaderFile +#include +#endif \ No newline at end of file diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx new file mode 100644 index 000000000..6dcfb8805 --- /dev/null +++ b/src/OBJECT/GEOM_Actor.cxx @@ -0,0 +1,450 @@ +using namespace std; +// File : GEOM_Actor.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Christophe ATTANASIO +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE 2002 +// $Header$ + +/*! + \class GEOM_Actor GEOM_Actor.h + \brief This class allows to display an OpenCASCADE CAD model in a VTK viewer. +*/ + +#include "GEOM_Actor.h" + +// VTK Includes +#include +#include +#include +#include + +// OpenCASCADE Includes +#include "GEOM_OCCReader.h" +#include + +//------------------------------------------------------------- +// 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(); +} diff --git a/src/OBJECT/GEOM_Actor.h b/src/OBJECT/GEOM_Actor.h new file mode 100644 index 000000000..85cd625e5 --- /dev/null +++ b/src/OBJECT/GEOM_Actor.h @@ -0,0 +1,114 @@ +// File : GEOM_Actor.h +// Created : Wed Feb 20 17:24:59 2002 +// Author : Christophe ATTANASIO +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef GEOM_ACTOR_H +#define GEOM_ACTOR_H + +#include "SALOME_Actor.h" + +//VTK +#include +#include +#include +#include + +//OpenCASCADE +#include +#include + + +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; + + int myDisplayMode; + +}; +#endif //GEOM_ACTOR_H diff --git a/src/OBJECT/GEOM_AssemblyBuilder.cxx b/src/OBJECT/GEOM_AssemblyBuilder.cxx new file mode 100644 index 000000000..fc06dd921 --- /dev/null +++ b/src/OBJECT/GEOM_AssemblyBuilder.cxx @@ -0,0 +1,388 @@ +using namespace std; +// File : GEOM_AssemblyBuilder.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Christophe ATTANASIO +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE 2002 +// $Header$ + +/*! + \class GEOM_AssemblyBuilder GEOM_AssemblyBuilder.h + \brief .... +*/ + +#include "GEOM_AssemblyBuilder.h" +#include "GEOM_Actor.h" +#include "utilities.h" + +// Open CASCADE Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// 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(); + + // 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 ) { + + // 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) +{ +} + + + + + diff --git a/src/OBJECT/GEOM_AssemblyBuilder.h b/src/OBJECT/GEOM_AssemblyBuilder.h new file mode 100644 index 000000000..abe459b91 --- /dev/null +++ b/src/OBJECT/GEOM_AssemblyBuilder.h @@ -0,0 +1,74 @@ +// File : GEOM_AssemblyBuilder.h +// Created : Wed Feb 20 17:24:59 2002 +// Author : Christophe ATTANASIO +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE 2002 +// $Header$ + +// VTK +#include +#include +#include + +// Open CASCADE Inlcudes +#include +#include + +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); + + +}; diff --git a/src/OBJECT/GEOM_InteractiveObject.cxx b/src/OBJECT/GEOM_InteractiveObject.cxx new file mode 100644 index 000000000..b8c484e4d --- /dev/null +++ b/src/OBJECT/GEOM_InteractiveObject.cxx @@ -0,0 +1,56 @@ +using namespace std; +// File : GEOM_InteractiveObject.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Christophe ATTANASIO +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE 2002 +// $Header$ + +/*! + \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; +} diff --git a/src/OBJECT/GEOM_InteractiveObject.hxx b/src/OBJECT/GEOM_InteractiveObject.hxx new file mode 100644 index 000000000..94325174a --- /dev/null +++ b/src/OBJECT/GEOM_InteractiveObject.hxx @@ -0,0 +1,116 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _GEOM_InteractiveObject_HeaderFile +#define _GEOM_InteractiveObject_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_GEOM_InteractiveObject_HeaderFile +#include "Handle_GEOM_InteractiveObject.hxx" +#endif + +#ifndef _Standard_CString_HeaderFile +#include +#endif +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#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 diff --git a/src/OBJECT/GEOM_InteractiveObject.ixx b/src/OBJECT/GEOM_InteractiveObject.ixx new file mode 100644 index 000000000..96844009f --- /dev/null +++ b/src/OBJECT/GEOM_InteractiveObject.ixx @@ -0,0 +1,71 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "GEOM_InteractiveObject.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#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() {} + diff --git a/src/OBJECT/GEOM_InteractiveObject.jxx b/src/OBJECT/GEOM_InteractiveObject.jxx new file mode 100644 index 000000000..1f74c76f4 --- /dev/null +++ b/src/OBJECT/GEOM_InteractiveObject.jxx @@ -0,0 +1,6 @@ +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _GEOM_InteractiveObject_HeaderFile +#include "GEOM_InteractiveObject.hxx" +#endif diff --git a/src/OBJECT/GEOM_OCCReader.cxx b/src/OBJECT/GEOM_OCCReader.cxx new file mode 100644 index 000000000..37edbea44 --- /dev/null +++ b/src/OBJECT/GEOM_OCCReader.cxx @@ -0,0 +1,968 @@ +using namespace std; +// File : GEOM_OCCReader.h +// Created : Wed Feb 20 17:24:59 2002 +// Author : Christophe ATTANASIO +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "GEOM_OCCReader.h" + +// SALOME Includes +#include "utilities.h" + +// VTK Includes +#include +#include + +// OpenCASCADE Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#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: "<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;jInsertNextPoint(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;jInsertNextPoint(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;iInsertNextCell(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; +} + + diff --git a/src/OBJECT/GEOM_OCCReader.h b/src/OBJECT/GEOM_OCCReader.h new file mode 100644 index 000000000..3c3b7204a --- /dev/null +++ b/src/OBJECT/GEOM_OCCReader.h @@ -0,0 +1,122 @@ +// File : GEOM_OCCReader.h +// Created : Wed Feb 20 17:24:59 2002 +// Author : Christophe ATTANASIO +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE 2002 +// $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 +#include +#include + +// OpenCASCADE +#include +#include +#include +#include +#include +#include + +#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 diff --git a/src/OBJECT/Handle_GEOM_AISShape.hxx b/src/OBJECT/Handle_GEOM_AISShape.hxx new file mode 100644 index 000000000..2642cefa3 --- /dev/null +++ b/src/OBJECT/Handle_GEOM_AISShape.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_GEOM_AISShape_HeaderFile +#define _Handle_GEOM_AISShape_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#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 diff --git a/src/OBJECT/Handle_GEOM_InteractiveObject.hxx b/src/OBJECT/Handle_GEOM_InteractiveObject.hxx new file mode 100644 index 000000000..b310ef892 --- /dev/null +++ b/src/OBJECT/Handle_GEOM_InteractiveObject.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_GEOM_InteractiveObject_HeaderFile +#define _Handle_GEOM_InteractiveObject_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#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 diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in new file mode 100644 index 000000000..be5adc735 --- /dev/null +++ b/src/OBJECT/Makefile.in @@ -0,0 +1,41 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:$(srcdir):$(top_srcdir)/idl:$(top_builddir)/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) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome + +%_moc.cxx: %.h + $(MOC) $< -o $@ + + +@CONCLUDE@ diff --git a/src/SKETCHER/GEOM_Sketcher.cxx b/src/SKETCHER/GEOM_Sketcher.cxx new file mode 100644 index 000000000..4e2010002 --- /dev/null +++ b/src/SKETCHER/GEOM_Sketcher.cxx @@ -0,0 +1,1372 @@ +using namespace std; +// File : GEOM_Sketcher.cxx +// Created : Wed Jul 5 10:12:09 2000 +// Author : Martine LANGLOIS + +// Modified : Tue Dec 11 21:28:07 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "GEOM_Sketcher.h" +#include "utilities.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +/*! + \class GEOM_Sketcher GEOM_Sketcher.h + \brief ... +*/ + +Standard_Real resol = 1.0; + +/*! + Constructor. +*/ +Sketch::Sketch() +{ + +} + +/*! + Destructor. +*/ +Sketch::~Sketch() +{ + +} + + +/*! + Constructor. + + \param V3d_Viewer +*/ +Sketch::Sketch(const Handle(V3d_Viewer)& aViewer) : +myInteractiveContext(new AIS_InteractiveContext(aViewer)), +myAxisColor(Quantity_Color(Quantity_NOC_YELLOW)), +myCurrentColor(Quantity_Color(Quantity_NOC_GREEN)), +myWireColor(Quantity_Color(Quantity_NOC_RED)) +{ + Init(); +} + +/*! + Constructor. + + \param V3d_Viewer + \param Quantity_Color + \param Quantity_Color + \param Quantity_Color +*/ +Sketch::Sketch(const Handle(V3d_Viewer)& aViewer, + const Quantity_Color& anAxisColor, + const Quantity_Color& aCurrentColor, + const Quantity_Color& aWireColor): +myInteractiveContext(new AIS_InteractiveContext(aViewer)), +myAxisColor(anAxisColor), +myCurrentColor(aCurrentColor), +myWireColor(aWireColor) +{ + Init(); +} + +/*! + Build the current edge in a graphic mode. + The first signature with view coordinates is used to connect to the move event from the user interface. + The second signature is used when the current point is known by 2d real coordinates. + + \param Xp + \param Yp + \param V3d_View +*/ +void Sketch::MakeCurrentEdge(const Standard_Integer Xp , + const Standard_Integer Yp , + const Handle(V3d_View)& aView ) +{ + /* 3d coordinates of the picked point */ + Standard_Real Xv,Yv,Zv; + aView->Convert(Xp,Yp,Xv,Yv,Zv); + /* computation of real 2d coordinates in plane of sketch */ + Standard_Real Vx,Vy,Vz; + aView->Proj(Vx,Vy,Vz); + gp_Dir D(Vx,Vy,Vz); + gp_Pnt P(Xv,Yv,Zv); + gp_Lin L(P,D); + Standard_Real X,Y; + gp_Pnt Sol; + IntAna_IntConicQuad Int(L,myPlane->Pln(),Precision::Angular()); + if (Int.IsDone()) { + if (!Int.IsParallel()) { + if (Int.NbPoints() > 0 ) { + Sol = Int.Point(1); + ElSLib::Parameters(myPlane->Pln(),Sol,X,Y); + } + } + } + MakeCurrentEdge(X,Y); +} + +/*! + Build the current edge in a graphic mode. + The first signature with view coordinates is used to connect to the move event from the user interface. + The second signature is used when the current point is known by 2d real coordinates. + + \param X + \param Y +*/ +void Sketch::MakeCurrentEdge(const Standard_Real X, const Standard_Real Y) +{ + /* Create the current edge depending on the active mode */ + switch (myCurrentStatus) { + case BEGIN_SKETCH: + myCurrentEdge = BRepBuilderAPI_MakeVertex(ElCLib::To3d(myPlane->Pln().Position().Ax2(),gp_Pnt2d(X,Y))); + break; + case SEGMENT: + MakeCurrentSegment(X,Y); + break; + case ARC_CHORD: + MakeCurrentSegment(X,Y); + break; + case ARC_CHORD_END: + MakeCurrentArc(X,Y); + break; + } + DisplayCurrentEdge(); +} + +/*! + Build the current edge in a graphic mode. + Function to connect to the input event from the user interface. +*/ +void Sketch::ValidateEdge() +{ + gp_Pnt pt; + gp_Pnt2d pt2d; + switch (myCurrentStatus) { + case BEGIN_SKETCH: + { + myFirstPointSketch = TopoDS::Vertex(myCurrentEdge); + myPresentableWire = new AIS_Shape(myFirstPointSketch); + myPresentableWire->SetColor(myWireColor.Name()); + myInteractiveContext->Display(myPresentableWire); + pt = BRep_Tool::Pnt(myFirstPointSketch); + pt2d = ProjLib::Project(myPlane->Pln(),pt); + myLastX = pt2d.X(); + myLastY = pt2d.Y(); + myCurrentStatus = SEGMENT; + break; + } + case SEGMENT: + { + Standard_Real first,last; + TopLoc_Location L; + Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(TopoDS::Edge(myCurrentEdge),myPlane,L,first,last); + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(Handle(Geom2d_Line)::DownCast(C)->Lin2d(),0.,myLengthDimension->Value()); + if (myTransitionStatus == ANGLE || + myTransitionStatus == LENGTH_FIXED || + myTransitionStatus == X_FIXED || + myTransitionStatus == Y_FIXED) + myTransitionStatus = NOCONSTRAINT; + AddEdgeToWire(); + break; + } + case ARC_CHORD: + { + myInteractiveContext->CloseLocalContext(); + myInteractiveContext->OpenLocalContext(); + gp_Pnt2d p1 (myLastX,myLastY); + pt = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(myCurrentEdge))); + gp_Pnt2d p2 = ProjLib::Project(myPlane->Pln(),pt); + GccAna_Pnt2dBisec ComputeMediatrice(p1,p2); + if (ComputeMediatrice.HasSolution()) { + myMediatrice = new Geom2d_Line(ComputeMediatrice.ThisSolution()); + Handle(Geom_Curve) aMediatrice3d = GeomAPI::To3d(myMediatrice,myPlane->Pln()); + myPresentableMediatrice = new AIS_Axis(Handle(Geom_Line)::DownCast(aMediatrice3d)); + myInteractiveContext->Display(myPresentableMediatrice); + } + TopoDS_Edge e = BRepBuilderAPI_MakeEdge2d(gce_MakeCirc2d(gp_Pnt2d(0.,0),1.)); + BRepLib::BuildCurve3d(e); + myLengthDimension->SetText(TCollection_ExtendedString()); + myInteractiveContext->Redisplay(myLengthDimension,Standard_False); + if (myEdgesNumber == 0) + myPreviousEdge = TopoDS::Edge(myCurrentEdge); + pt2d = ProjLib::Project(myPlane->Pln(),pt); + myLastX = pt2d.X(); + myLastY = pt2d.Y(); + myTransitionStatus = NOCONSTRAINT; + myCurrentStatus = ARC_CHORD_END; + break; + } + case ARC_CHORD_END: + myCurrentStatus = ARC_CHORD; + AddEdgeToWire(); + break; + } +} + +/*! + Add edge to current wire on an edge validation . +*/ +void Sketch::AddEdgeToWire() +{ + myPreviousEdge = TopoDS::Edge(myCurrentEdge); + BRepLib::BuildCurve3d(myPreviousEdge); + myCurrentWire.Add(TopoDS::Edge(myPreviousEdge)); + myEdgesNumber++; + myPresentableWire->Set( myCurrentWire.Wire() ); + myInteractiveContext->Redisplay(myPresentableWire); + myConstructionMode.Append(myCurrentStatus); + myConstraintMode.Append(myTransitionStatus); + myInteractiveContext->CloseLocalContext(); + gp_Pnt pt; + if (myPreviousEdge.Orientation() == TopAbs_FORWARD ) + pt = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(myPreviousEdge))); + else + pt = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(myPreviousEdge))); + gp_Pnt2d pt2d= ProjLib::Project(myPlane->Pln(),pt); + myLastX = pt2d.X(); + myLastY = pt2d.Y(); +} + +/*! + Set the numeric dimension for the current edge and validate creation. + + \param aValue + \return Standard_Boolean +*/ +Standard_Boolean Sketch::SetDimension(Standard_Real& aValue) +{ + fitInResol(aValue); + if (myCurrentStatus == SEGMENT || + myCurrentStatus == ARC_CHORD){ + Standard_Real first,last; + TopLoc_Location L; + Handle(Geom2d_Curve) C = + BRep_Tool::CurveOnSurface(TopoDS::Edge(myCurrentEdge),myPlane,L,first,last); + myCurrentEdge = + BRepBuilderAPI_MakeEdge2d(Handle(Geom2d_Line)::DownCast(C)->Lin2d(),0.,aValue); + DisplayCurrentEdge(); + if (myTransitionStatus == NOCONSTRAINT) { + mySegmentLength = aValue; + myTransitionStatus = LENGTH_FIXED; + } + else + ValidateEdge(); + return Standard_True; + } + + else if( myCurrentStatus == ARC_CHORD_END){ + if (myTransitionStatus == TANGENT) return Standard_False; + gp_Pnt2d p; + if (myEdgesNumber > 0) { + if (myPreviousEdge.Orientation() == TopAbs_FORWARD) + p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::LastVertex(myPreviousEdge))); + else + p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::FirstVertex(myPreviousEdge))); + } + else + p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(myFirstPointSketch)); + GccAna_Circ2d2TanRad aSol(p, gp_Pnt2d(myLastX,myLastY),aValue,Precision::Confusion()); + Standard_Real dist = RealLast(); + if (aSol.NbSolutions() > 0) { + gp_Circ2d CirSol; + gp_Pnt2d pc = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopoDS::Vertex(myCenterCircle->Shape()))); + for (Standard_Integer i =1; i<= aSol.NbSolutions(); i++) { + if (pc.Distance(aSol.ThisSolution(i).Location()) < dist) + CirSol = aSol.ThisSolution(i); + } + if (myCurrentEdge.Orientation() == TopAbs_FORWARD) + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aSol.ThisSolution(1),p,gp_Pnt2d(myLastX,myLastY)); + else { + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aSol.ThisSolution(1),gp_Pnt2d(myLastX,myLastY),p); + myCurrentEdge.Reverse(); + } + DisplayCurrentEdge(); + ValidateEdge(); + return Standard_True; + } + } + + return Standard_False; +} + +/*! + Set the numeric dimension for the current edge and validate creation. + + \param deltaX + \param deltaY +*/ +void Sketch::SetDimension(Standard_Real& deltaX, Standard_Real& deltaY) +{ + fitInResol(deltaX); + fitInResol(deltaY); + Standard_Real X = myLastX + deltaX; + Standard_Real Y = myLastY + deltaY; + MakeCurrentEdge(X,Y); + ValidateEdge(); +} + +/*! + Set the numeric value of the X coordinate of current point giving a deltaX relative to previous point. + + \param deltaX +*/ +void Sketch::SetXDimension(Standard_Real& deltaX) +{ + fitInResol(deltaX); + Standard_Real X = myLastX + deltaX; + Standard_Real Y = myLastY; + if ( deltaX == 0. ) + Y = Y + 100.0 * Precision::Confusion(); + + if (myTransitionStatus == NOCONSTRAINT) { + MakeCurrentEdge(X,Y); + myTransitionStatus = X_FIXED; + mySegmentX = X; + } + else if (myTransitionStatus == Y_FIXED) { + myTransitionStatus = NOCONSTRAINT; + MakeCurrentEdge(X,mySegmentY); + ValidateEdge(); + } + else if (myTransitionStatus == ANGLE) { + myTransitionStatus = NOCONSTRAINT; + Standard_Real angle; + if (0 <= mySegmentAngle && mySegmentAngle<= PI ) + angle = PI - mySegmentAngle; + else + angle = mySegmentAngle - PI; + Y = X*Tan(angle); + MakeCurrentEdge(X,Y); + ValidateEdge(); + } + else + myTransitionStatus = NOCONSTRAINT; +} + +/*! + Set the numeric value of the Y coordinate of current point giving a deltaY relative to previous point. + + \param deltaY +*/ +void Sketch::SetYDimension(Standard_Real& deltaY) +{ + fitInResol(deltaY); + Standard_Real X = myLastX; + Standard_Real Y = myLastY + deltaY; + + if ( deltaY == 0. ) + X = X + 100.0 * Precision::Confusion(); + + if (myTransitionStatus == NOCONSTRAINT) { + MakeCurrentEdge(X,Y); + myTransitionStatus = Y_FIXED; + mySegmentY = Y; + } + else if (myTransitionStatus == X_FIXED) { + myTransitionStatus = NOCONSTRAINT; + MakeCurrentEdge(mySegmentX,Y); + ValidateEdge(); + } + else if (myTransitionStatus == ANGLE) { + myTransitionStatus = NOCONSTRAINT; + Standard_Real angle; + if (0 <= mySegmentAngle && mySegmentAngle<= PI ) + angle = PI - mySegmentAngle; + else + angle = mySegmentAngle - PI; + X = Y/Tan(angle); + MakeCurrentEdge(X,Y); + ValidateEdge(); + } + else + myTransitionStatus = NOCONSTRAINT; +} + +/*! + Set the numeric value of angle between 2 segments. + + \param aValue +*/ +void Sketch::SetSegmentAngle(Standard_Real& aValue) +{ + if (myEdgesNumber > 0) { + Standard_Real First,Last; + TopLoc_Location L; + Standard_Real angle; + if (0 <= aValue && aValue<= PI ) + angle = PI - aValue; + else + angle = aValue - PI; + Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last); + if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) { + Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myPreviousEdge),myPlane,L,First,Last); + + GccAna_Lin2dTanObl aSol(gp_Pnt2d(myLastX,myLastY),Handle(Geom2d_Line)::DownCast(PreviousCurve)->Lin2d(),angle); + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aSol.ThisSolution(1),0.,myLengthDimension->Value()); + } + if (myTransitionStatus == LENGTH_FIXED) { + ValidateEdge(); + } + else if (myTransitionStatus == X_FIXED) { + Standard_Real length = mySegmentX/Cos(angle); + SetDimension(length); + ValidateEdge(); + } + else if (myTransitionStatus == Y_FIXED) { + Standard_Real length = mySegmentY/Sin(angle); + SetDimension(length); + ValidateEdge(); + } + else { + mySegmentAngle = aValue; + myTransitionStatus = ANGLE; + } + } +} + +/*! + Get the angle value between 2 segments. + + \return Standard_Real +*/ +Standard_Real Sketch::GetSegmentAngle() +{ + return mySegmentAngle; +} + +/*! + Close automatically an open sketch. + + \return TopoDS_Wire. Return null shape if not possible. +*/ +TopoDS_Wire Sketch::Close() +{ + myCurrentStatus = END_SKETCH; + myInteractiveContext->CloseAllContexts(); + myInteractiveContext->EraseAll(Standard_False); + if (myEdgesNumber >= 2) { + BRepTools_WireExplorer Ex(myCurrentWire.Wire()); + TopoDS_Vertex V1; + if (myPreviousEdge.Orientation() == TopAbs_FORWARD) + V1 = TopExp::LastVertex(myPreviousEdge); + else + V1 = TopExp::FirstVertex(myPreviousEdge); + myCurrentWire.Add(BRepBuilderAPI_MakeEdge(V1,myFirstPointSketch).Edge()); + myEdgesNumber++; + return myCurrentWire.Wire(); + } + else + return TopoDS_Wire(); +} + + + +/*! + Clear sketch presentation. +*/ +void Sketch::Clear() +{ + myCurrentStatus = END_SKETCH; + myInteractiveContext->CloseAllContexts(); + myInteractiveContext->EraseAll(Standard_False); +} + +/*! + Terminate sketch without closing. + + \return TopoDS_Wire. Return null shape if not possible. +*/ +TopoDS_Wire Sketch::End() +{ + myCurrentStatus = END_SKETCH; + myInteractiveContext->CloseAllContexts(); + myInteractiveContext->EraseAll(Standard_False); + if (myCurrentWire.IsDone()) { + return myCurrentWire.Wire(); + } + else + return TopoDS_Wire(); +} + + +/*! + Delete current edge. +*/ +Standard_Boolean Sketch::Delete() +{ + myInteractiveContext->Erase(myAngleDimension,Standard_True,Standard_False); + myInteractiveContext->Erase(myLengthDimension,Standard_True,Standard_False); + myInteractiveContext->Erase(myRadiusDimension,Standard_True,Standard_False); + myInteractiveContext->Erase(myCenterCircle,Standard_True,Standard_False); + myInteractiveContext->Erase(myXDimension,Standard_True,Standard_False); + myInteractiveContext->Erase(myYDimension,Standard_True,Standard_False); + + if (myCurrentStatus == BEGIN_SKETCH) { + myCurrentStatus = END_SKETCH; + myInteractiveContext->CloseAllContexts(); + myInteractiveContext->EraseAll(Standard_False); + return true; + } + else if(myCurrentStatus == SEGMENT || + myCurrentStatus == ARC_CHORD ) { + RemoveLastEdge(); + } + else if(myCurrentStatus == ARC_CHORD_END) { + myCurrentStatus = ARC_CHORD; + myInteractiveContext->CloseAllContexts(); + } + gp_Pnt pt; + if (myEdgesNumber == 0) { + //myInteractiveContext->EraseAll(Standard_False); + ChangeMode(BEGIN_SKETCH); // DCQ + pt = BRep_Tool::Pnt(myFirstPointSketch); + } + else { + if (myPreviousEdge.Orientation() == TopAbs_FORWARD ) + pt = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(myPreviousEdge))); + else + pt = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(myPreviousEdge))); + } + gp_Pnt2d pt2d= ProjLib::Project(myPlane->Pln(),pt); + myLastX = pt2d.X(); + myLastY = pt2d.Y(); + + return false; +} + +/*! + Set a specific plane for sketch. + + \param GeomyPlane +*/ +void Sketch::SetPlane(const Handle(Geom_Plane)& aPlane) +{ + myPlane = aPlane; +} + +/*! + Set display parameters. + + \param aColor +*/ +void Sketch::SetWireColor(const Quantity_Color& aColor) +{ + myWireColor = aColor; +} + +/*! + Set display parameters. + + \param aColor +*/ +void Sketch::SetCurrentColor(const Quantity_Color& aColor) +{ + myCurrentColor = aColor; +} + +/*! + Set display parameters. + + \param aColor +*/ +void Sketch::SetAxisColor(const Quantity_Color& aColor) +{ + myAxisColor = aColor; +} + + +/*! + Change mode of construction line. + + \param aMode : SEGMENT, ARC_CHORD. +*/ +void Sketch::ChangeMode(const SketchStatus aMode) +{ + gp_Pnt2d p; + if (myEdgesNumber > 0) { + if (myPreviousEdge.Orientation() == TopAbs_FORWARD) + p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::LastVertex(myPreviousEdge))); + else + p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::FirstVertex(myPreviousEdge))); + myLastX = p.X(); + myLastY = p.Y(); + myInteractiveContext->CloseLocalContext(myInteractiveContext->IndexOfCurrentLocal()); + } + if (!myCurrentStatus == BEGIN_SKETCH) + myCurrentStatus = aMode; /* change the mode only when the sketch is not in state BEGIN_SKETCH, i.d. fist point has been fixed */ + +} + +/*! + Set transition constraint between consecutive edges. + + \param aStatus : NOCONSTRAINT, TANGENT, PERPENDICULAR, ANGLE, LENGTH_FIXED, X_FIXED, Y_FIXED. +*/ +void Sketch::SetTransitionStatus(const TransitionStatus aStatus) +{ + myTransitionStatus = aStatus; +} + +/*! + Set or unset the display of dimensions. + + \param atype + \param OnOff +*/ +void Sketch::SetParameterVisibility(const TypeOfParameter atype, const Standard_Boolean OnOff) +{ + switch (atype) { + case ANGLE_PARAMETER: + myIsAngleDimensionVisible = OnOff; + if (!myIsAngleDimensionVisible && !myAngleDimension.IsNull()) + myInteractiveContext->Erase(myAngleDimension,Standard_True,Standard_False); + //else DCQ + // DisplayCurrentEdge(); + break; + case LENGTH_PARAMETER: + myIsLengthDimensionVisible = OnOff; + if (!myIsLengthDimensionVisible&& !myLengthDimension.IsNull()) + myInteractiveContext->Erase(myLengthDimension,Standard_True,Standard_False); + //else DCQ + // DisplayCurrentEdge(); + break; + case RADIUS_PARAMETER: + myIsRadiusDimensionVisible = OnOff; + if (!myIsRadiusDimensionVisible&& !myRadiusDimension.IsNull()){ + myInteractiveContext->Erase(myRadiusDimension,Standard_True,Standard_False); + myInteractiveContext->Erase(myCenterCircle,Standard_True,Standard_False); + } + //else DCQ + // DisplayCurrentEdge(); + break; + case XVALUE_PARAMETER: + myIsXDimensionVisible = OnOff; + if (!myIsXDimensionVisible&& !myXDimension.IsNull()) + myInteractiveContext->Erase(myXDimension,Standard_True,Standard_False); + break; + case YVALUE_PARAMETER: + myIsYDimensionVisible = OnOff; + if (!myIsYDimensionVisible&& !myYDimension.IsNull()) + myInteractiveContext->Erase(myYDimension,Standard_True,Standard_False); + break; + } +} + +/*! + Hilight parameters. + + \param atype + \param acolor +*/ +void Sketch::HiligthWithColor(const TypeOfParameter atype, const Quantity_NameOfColor acolor) +{ + switch (atype) { + case ANGLE_PARAMETER: + myInteractiveContext->HilightWithColor(myAngleDimension, acolor); + break; + case LENGTH_PARAMETER: + myInteractiveContext->HilightWithColor(myLengthDimension, acolor); + break; + case RADIUS_PARAMETER: + myInteractiveContext->HilightWithColor(myRadiusDimension, acolor); + break; + case XVALUE_PARAMETER: + myInteractiveContext->HilightWithColor(myXDimension, acolor); + break; + case YVALUE_PARAMETER: + myInteractiveContext->HilightWithColor(myYDimension, acolor); + break; + } +} + + +/*! + Unhilight parameters. + + \param atype +*/ +void Sketch::Unhiligth(const TypeOfParameter atype) +{ + switch (atype) { + case ANGLE_PARAMETER: + myInteractiveContext->Unhilight(myAngleDimension); + break; + case LENGTH_PARAMETER: + myInteractiveContext->Unhilight(myLengthDimension); + break; + case RADIUS_PARAMETER: + myInteractiveContext->Unhilight(myRadiusDimension); + break; + case XVALUE_PARAMETER: + myInteractiveContext->Unhilight(myXDimension); + break; + case YVALUE_PARAMETER: + myInteractiveContext->Unhilight(myYDimension); + break; + } +} + +/*! + Check if the edition of a type of parameter is relevant depending on sketch current status. + + \param atype + \return Standard_Boolean +*/ +Standard_Boolean Sketch::IsValidCurrentParameter(const TypeOfParameter atype) +{ + switch (atype) { + case ANGLE_PARAMETER: + if (myCurrentStatus != SEGMENT && myCurrentStatus != ARC_CHORD) + return Standard_False; + else if (myTransitionStatus == TANGENT || myTransitionStatus == PERPENDICULAR) + return Standard_False; + else if (myEdgesNumber < 1) + return Standard_False; + else { + TopLoc_Location L; + Standard_Real First,Last; + Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last); + if (!PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) + return Standard_False; + } + break; + case LENGTH_PARAMETER: + if (myCurrentStatus != SEGMENT && + myCurrentStatus != ARC_CHORD /*&& + myCurrentStatus != CURVE_POINTS*/ + ) + return Standard_False; + else if (myTransitionStatus == LENGTH_FIXED) + return Standard_False; + break; + case RADIUS_PARAMETER: + if (myCurrentStatus != ARC_CHORD_END) + return Standard_False; + break; + case XVALUE_PARAMETER: + if (myCurrentStatus != SEGMENT && + myCurrentStatus != ARC_CHORD /*&& + myCurrentStatus != CURVE_POINTS*/ + ) + return Standard_False; + else if (myTransitionStatus == X_FIXED) + return Standard_False; + break; + case YVALUE_PARAMETER: + if (myCurrentStatus != SEGMENT && + myCurrentStatus != ARC_CHORD /*&& + myCurrentStatus != CURVE_POINTS*/ + ) + return Standard_False; + else if (myTransitionStatus == Y_FIXED) + return Standard_False; + break; + } + return Standard_True; +} + +/*! + Set a parameter value. + + \param atype + \param aValue +*/ +void Sketch::SetParameterValue(const TypeOfParameter atype, Standard_Real aValue) +{ + switch (atype) { + case ANGLE_PARAMETER: + SetSegmentAngle(aValue); + break; + case LENGTH_PARAMETER: + SetDimension(aValue); + break; + case RADIUS_PARAMETER: + SetDimension(aValue); + break; + case XVALUE_PARAMETER: + SetXDimension(aValue); + break; + case YVALUE_PARAMETER: + SetYDimension(aValue); + break; + } +} + +/*! + Initialisation of sketch parameters or options. +*/ +void Sketch::Init() +{ + myPlane = new Geom_Plane (0.,0.,1.,0.); + CreateConstraints(); + BRepLib::Plane(myPlane); + myEdgesNumber = 0; + myCurrentStatus = BEGIN_SKETCH; + /* In order to update the visulisation of current objects by using Redisplay method from InteractiveContext */ + myCurrentEdge = BRepBuilderAPI_MakeVertex(gp_Pnt(0.,0.,0.)); + myPresentableEdge = new AIS_Shape(myCurrentEdge); + myPresentableEdge->SetColor(myCurrentColor.Name()); + myInteractiveContext->Display(myPresentableEdge); + myTransitionStatus = NOCONSTRAINT; + /* Init for display objects */ + TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.,0.,0.)); + TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10.,0.,0.)); + myLengthDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString()); + myXDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString(),gp_Pnt(),DsgPrs_AS_NONE, + AIS_TOD_Horizontal); + myYDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString(),gp_Pnt(),DsgPrs_AS_NONE, + AIS_TOD_Vertical); + myRadiusDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString()); + myCenterCircle = new AIS_Shape(V1); + myIsLengthDimensionVisible = Standard_False; + myIsXDimensionVisible = Standard_False; + myIsYDimensionVisible = Standard_False; + myIsRadiusDimensionVisible = Standard_False; +} + +/*! + Build the current segment. + + \param X + \param Y +*/ +void Sketch::MakeCurrentSegment(Standard_Real X, Standard_Real Y) +{ + if (myTransitionStatus == NOCONSTRAINT) + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY), gp_Pnt2d(X,Y)); + else if (myTransitionStatus == X_FIXED) + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY),gp_Pnt2d(mySegmentX,Y)); + else if (myTransitionStatus == Y_FIXED) + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY),gp_Pnt2d(X,mySegmentY)); + else if (myTransitionStatus == TANGENT && myEdgesNumber > 0) { + Standard_Real first,last; + TopLoc_Location L; + Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last); + gp_Pnt2d p1; + gp_Vec2d Vt; + if (myPreviousEdge.Orientation() == TopAbs_FORWARD) + C->D1(last,p1,Vt); + else + C->D1(first,p1,Vt); + gp_Lin2d aline(p1,Vt); + Geom2dAPI_ProjectPointOnCurve proj(gp_Pnt2d(X,Y),new Geom2d_Line(aline)); + if (proj.NbPoints() > 0) + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(p1,proj.Point(1)); + } + else if (myTransitionStatus == PERPENDICULAR && myEdgesNumber > 0) { + Standard_Real first,last; + TopLoc_Location L; + Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last); + gp_Pnt2d p1; + gp_Lin2d perpen; + if (myPreviousEdge.Orientation() == TopAbs_FORWARD) + C->D0(last,p1); + else + C->D0(first,p1); + if (C->IsKind(STANDARD_TYPE(Geom2d_Line))) { + GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Line)::DownCast(C)->Lin2d()); + perpen = aSol.ThisSolution(1); + } + else if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) { + GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Circle)::DownCast(C)->Circ2d()); + perpen = aSol.ThisSolution(1); + } + Geom2dAPI_ProjectPointOnCurve proj(gp_Pnt2d(X,Y),new Geom2d_Line(perpen)); + if (proj.NbPoints() > 0) + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(p1,proj.Point(1)); + } + else if (myTransitionStatus == ANGLE && myEdgesNumber > 0) { + Standard_Real First,Last; + TopLoc_Location L; + Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last); + if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) { + Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myPreviousEdge),myPlane,L,First,Last); + Standard_Real angle; + if (0 <= mySegmentAngle && mySegmentAngle<= PI ) + angle = PI - mySegmentAngle; + else + angle = mySegmentAngle - PI; + GccAna_Lin2dTanObl aSol(gp_Pnt2d(myLastX,myLastY),Handle(Geom2d_Line)::DownCast(PreviousCurve)->Lin2d(),angle); + Standard_Real dist = RealLast(); + gp_Pnt2d pt(X,Y),ptproj; + for (Standard_Integer i =1; i<=aSol.NbSolutions(); i++) { + Geom2dAPI_ProjectPointOnCurve proj(pt,new Geom2d_Line(aSol.ThisSolution(i))); + if (pt.Distance(proj.Point(1)) < dist) { + dist = pt.Distance(proj.Point(1)); + ptproj = proj.Point(1); + } + } + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY),ptproj); + } + } + else if (myTransitionStatus == LENGTH_FIXED && myEdgesNumber > 0) { + Standard_Real First,Last; + TopLoc_Location L; + Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last); + if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) { + Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myPreviousEdge),myPlane,L,First,Last); + gp_Lin2d aline = gce_MakeLin2d(gp_Pnt2d(myLastX,myLastY), gp_Pnt2d(X,Y)); + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aline,0.,mySegmentLength); + } + } +} + +/*! + Build the current arc. + + \param X + \param Y +*/ +void Sketch::MakeCurrentArc(Standard_Real X, Standard_Real Y) +{ + gp_Circ2d CircSol; + Standard_Boolean OK(Standard_False); + + if (myTransitionStatus == NOCONSTRAINT) { + GccAna_Circ2d2TanOn aSol(gp_Pnt2d(myLastX,myLastY), gp_Pnt2d(X,Y),myMediatrice->Lin2d(),Precision::Confusion()); + if (aSol.NbSolutions() > 0){ + CircSol = aSol.ThisSolution(1); + OK = Standard_True; + } + } + /* Tangency with previous edge */ + else if (myTransitionStatus == TANGENT && myEdgesNumber > 0) { + Standard_Real first,last; + TopLoc_Location L; + Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last); + if (C->IsKind(STANDARD_TYPE(Geom2d_Line))){ + GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(Handle(Geom2d_Line)::DownCast(C)->Lin2d()), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion()); + if (aSol.NbSolutions() > 0){ + CircSol = aSol.ThisSolution(1); + OK = Standard_True; + } + } + else if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) { + GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(Handle(Geom2d_Circle)::DownCast(C)->Circ2d()), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion()); + if (aSol.NbSolutions() > 0){ + CircSol = aSol.ThisSolution(1); + OK = Standard_True; + } + } + else if(C->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) { + gp_Pnt2d pc; + gp_Vec2d Vt; + C->D1(last,pc,Vt); + gp_Lin2d alin2d(pc,gp_Dir2d(Vt)); + GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(alin2d), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion()); + if (aSol.NbSolutions() > 0){ + CircSol = aSol.ThisSolution(1); + OK = Standard_True; + } + } + } + /* Tangency with the perpendicular to the previous edge */ + else if (myTransitionStatus == PERPENDICULAR && myEdgesNumber > 0) { + Standard_Real first,last; + TopLoc_Location L; + Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last); + gp_Pnt2d p1; + gp_Lin2d perpen; + if (myPreviousEdge.Orientation() == TopAbs_FORWARD) + C->D0(last,p1); + else + C->D0(first,p1); + if (C->IsKind(STANDARD_TYPE(Geom2d_Line))) { + GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Line)::DownCast(C)->Lin2d()); + perpen = aSol.ThisSolution(1); + } + else if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) { + GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Circle)::DownCast(C)->Circ2d()); + perpen = aSol.ThisSolution(1); + } + GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(perpen), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion()); + if (aSol.NbSolutions() > 0){ + CircSol = aSol.ThisSolution(1); + OK = Standard_True; + } + } + + gp_Pnt2d p; + if (myEdgesNumber > 0) { + if (myPreviousEdge.Orientation() == TopAbs_FORWARD) + p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::LastVertex(myPreviousEdge))); + else + p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::FirstVertex(myPreviousEdge))); + } + else + p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(myFirstPointSketch)); + if (OK){ + gp_Vec2d V1(p,gp_Pnt2d(X,Y)); + gp_Vec2d V2(p,gp_Pnt2d(myLastX,myLastY)); + if (V1.Angle(V2) > 0 ) + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(CircSol,p,gp_Pnt2d(myLastX,myLastY)); + else { + myCurrentEdge = BRepBuilderAPI_MakeEdge2d(CircSol,gp_Pnt2d(myLastX,myLastY),p); + myCurrentEdge.Reverse(); + } + } + else { + myCurrentStatus = ARC_CHORD; + myLastX = p.X(); + myLastY = p.Y(); + myInteractiveContext->CloseLocalContext(); + } + +} + +/*! + Display the current edge under construction with it's dimension. +*/ +void Sketch::DisplayCurrentEdge() +{ + myPresentableEdge->Set(myCurrentEdge); + myInteractiveContext->Redisplay(myPresentableEdge); + if (myCurrentStatus == SEGMENT || + myCurrentStatus == ARC_CHORD ) { + /* Length dimension */ + TopoDS_Vertex V1 = TopExp::FirstVertex(TopoDS::Edge(myCurrentEdge)); + TopoDS_Vertex V2 = TopExp::LastVertex(TopoDS::Edge(myCurrentEdge)); + DisplayLengthDimension(V1,V2); + /* Angular dimension */ + DisplayAngleDimension(); + DisplayXDimension(V1,V2); + DisplayYDimension(V1,V2); + } + else if (myCurrentStatus == ARC_CHORD_END ) + DisplayRadiusDimension(); + else { + TopoDS_Vertex V1 = TopoDS::Vertex(myCurrentEdge); + TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.,0.,0.)); + DisplayXDimension(V1,V2); + DisplayYDimension(V1,V2); + } + +} + +/*! + Display the current length dimension. + + \param V1 + \param V2 +*/ +void Sketch::DisplayLengthDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2) +{ + gp_Pnt p1 = BRep_Tool::Pnt(TopoDS::Vertex(V1)); + gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(V2)); + Standard_Real length = p1.Distance(p2); + if (length <= Precision::Confusion()) return; + myLengthDimension->SetFirstShape(V1); + myLengthDimension->SetSecondShape(V2); + fitInResol(length); + myLengthDimension->SetValue(length); + QString S; + S.sprintf("%.1f",length); + myLengthDimension->SetText(TCollection_ExtendedString(strdup(S))); + if (myIsLengthDimensionVisible) { + if (myInteractiveContext->IsDisplayed(myLengthDimension)) + myInteractiveContext->Redisplay(myLengthDimension); + else + myInteractiveContext->Display(myLengthDimension); + } +} + +/*! + Display the current X dimension. + + \param V1 + \param V2 +*/ +void Sketch::DisplayXDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2) +{ + if (myTransitionStatus != X_FIXED) { + gp_Pnt p1 = BRep_Tool::Pnt(TopoDS::Vertex(V1)); + gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(V2)); + + gp_Lin aline(p1,myPlane->Pln().XAxis().Direction()); + GeomAPI_ProjectPointOnCurve proj(p2,new Geom_Line(aline)); + + gp_Pnt pb = p1; + + if (proj.NbPoints() > 0) { + Standard_Real length = p1.Distance(proj.Point(1)); + if (length <= Precision::Confusion()) return; + myXDimension->SetFirstShape(V1); + myXDimension->SetSecondShape(V2); + fitInResol(length); + myXDimension->SetValue(length); + QString S; + S.sprintf("%.1f",length); + myXDimension->SetText(TCollection_ExtendedString(strdup(S))); + // myXDimension->SetPosition(proj.Point(1)); + pb.BaryCenter(5,proj.Point(1),5); + myXDimension->SetPosition(pb); + if (myIsXDimensionVisible) { + if (myInteractiveContext->IsDisplayed(myXDimension)) + myInteractiveContext->Redisplay(myXDimension); + else + myInteractiveContext->Display(myXDimension); + } + } + } else + myInteractiveContext->Erase(myXDimension,Standard_True,Standard_False); +} + +/*! + Display the current Y dimension. + + \param V1 + \param V2 +*/ +void Sketch::DisplayYDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2) +{ + if (myTransitionStatus != Y_FIXED) { + + gp_Pnt p1 = BRep_Tool::Pnt(TopoDS::Vertex(V1)); + gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(V2)); + gp_Lin aline(p2 /*p1*/, myPlane->Pln().YAxis().Direction()); + gp_Pnt pb = p2 /*p1*/; + GeomAPI_ProjectPointOnCurve proj(p1 /*p2*/,new Geom_Line(aline)); + if (proj.NbPoints() > 0) { + Standard_Real length = /*p1*/ p2.Distance(proj.Point(1)); + if (length <= Precision::Confusion()) return; + myYDimension->SetFirstShape(V1); + myYDimension->SetSecondShape(V2); + fitInResol(length); + myYDimension->SetValue(length); + QString S; + S.sprintf("%.1f",length); + myYDimension->SetText(TCollection_ExtendedString(strdup(S))); + pb.BaryCenter(5,proj.Point(1),5); + myYDimension->SetPosition(pb); + // myYDimension->SetPosition(p2); + if (myIsYDimensionVisible) { + if (myInteractiveContext->IsDisplayed(myYDimension)) + myInteractiveContext->Redisplay(myYDimension); + else + myInteractiveContext->Display(myYDimension); + } + } + } else + myInteractiveContext->Erase(myYDimension,Standard_True,Standard_False); +} + +/*! + Display the current angle dimension. +*/ +void Sketch::DisplayAngleDimension() +{ + if (!myIsAngleDimensionVisible) + return; + if (myEdgesNumber > 0) { + Standard_Real First,Last; + TopLoc_Location L; + Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last); + Handle (Geom2d_Curve) CurrentCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myCurrentEdge),myPlane,L,First,Last); + if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line)) && CurrentCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) { + Standard_Real angle = Handle(Geom2d_Line)::DownCast(PreviousCurve)->Lin2d().Angle(Handle(Geom2d_Line)::DownCast(CurrentCurve)->Lin2d()); + gp_Pnt2d apos; + if (0 <= angle && angle<= PI) + angle = PI - angle; + else + angle = PI + angle; + CurrentCurve->D0((First+Last)/5.,apos); + gp_Pnt apos3d = ElCLib::To3d(myPlane->Pln().Position().Ax2(),apos); + Standard_Real angtext = angle*180./PI; + mySegmentAngle = angle; + BRepLib::BuildCurve3d(TopoDS::Edge(myCurrentEdge)); + fitInResol(angtext); + + QString S; + S.sprintf("%.1f",angtext); + if (myInteractiveContext->IndexOfCurrentLocal() == 0) { + myInteractiveContext->OpenLocalContext(); + myAngleDimension = new AIS_AngleDimension(myPreviousEdge,TopoDS::Edge(myCurrentEdge),myPlane,angle, + TCollection_ExtendedString(strdup(S))); + myInteractiveContext->Display(myAngleDimension); + } + else { + myAngleDimension->SetSecondShape(myCurrentEdge); + myAngleDimension->SetValue(angle); + myAngleDimension->SetPosition(apos3d); + myAngleDimension->SetText(TCollection_ExtendedString(strdup(S))); + myInteractiveContext->Redisplay(myAngleDimension); + } + } + } +} + +/*! + Display the current radius dimension. +*/ +void Sketch::DisplayRadiusDimension() +{ + if (! myIsRadiusDimensionVisible) + return; + BRepLib::BuildCurve3d(TopoDS::Edge(myCurrentEdge)); + Standard_Real First,Last; + Handle (Geom_Circle) C = Handle (Geom_Circle)::DownCast(BRep_Tool::Curve(TopoDS::Edge(myCurrentEdge),First,Last)); + if (!C.IsNull()) { + Standard_Real R = C->Radius(); + TopoDS_Shape V1 = BRepBuilderAPI_MakeVertex(C->Location()); + gp_Pnt MidlePoint ; + C->D0((First+Last)/2.,MidlePoint); + TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(MidlePoint); + myRadiusDimension->SetFirstShape(V1); + myRadiusDimension->SetSecondShape(V2); + myRadiusDimension->SetValue(R); + fitInResol(R); + QString S; + S.sprintf("%.1f",R); + myRadiusDimension->SetText(TCollection_ExtendedString(strdup(S))); + if (myInteractiveContext->IsDisplayed(myRadiusDimension)) + myInteractiveContext->Redisplay(myRadiusDimension); + else + myInteractiveContext->Display(myRadiusDimension); + myCenterCircle->Set(V1); + if (myInteractiveContext->IsDisplayed(myCenterCircle)) + myInteractiveContext->Redisplay(myCenterCircle); + else + myInteractiveContext->Display(myCenterCircle); + } +} + +/*! + Remove last edge from the current wire. +*/ +void Sketch::RemoveLastEdge() +{ + if (myEdgesNumber == 0) { + myCurrentStatus = END_SKETCH; + myInteractiveContext->CloseAllContexts(); + myInteractiveContext->EraseAll(Standard_False); + return; + } + else { + BRepTools_WireExplorer Ex; + BRepBuilderAPI_MakeWire MW; + Standard_Integer index = 1; + myCurrentEdge = myPreviousEdge; + for (Ex.Init(myCurrentWire.Wire());Ex.More();Ex.Next()){ + if (index <= myEdgesNumber-1) { + MW.Add(Ex.Current()); + myPreviousEdge = Ex.Current(); + index++; + } + } + myCurrentWire = MW; + myCurrentStatus = (SketchStatus)myConstructionMode(myEdgesNumber); + myTransitionStatus = (TransitionStatus)myConstraintMode(myEdgesNumber); + myEdgesNumber--; + myConstructionMode.Remove(index); + myConstraintMode.Remove(index); + if (myEdgesNumber == 0) + myPresentableWire->Set(myFirstPointSketch); + else + myPresentableWire->Set(myCurrentWire.Wire()); + myInteractiveContext->Redisplay(myPresentableWire); + myInteractiveContext->CloseLocalContext(); + myPresentableEdge->Set(myCurrentEdge); + myInteractiveContext->Redisplay(myPresentableEdge); + } +} + +/*! + Create initial constraints. +*/ +void Sketch::CreateConstraints() +{ + Handle(Geom_Axis1Placement) xAxis = new Geom_Axis1Placement(myPlane->Pln().XAxis()); + Handle(Geom_Axis1Placement) yAxis = new Geom_Axis1Placement(myPlane->Pln().YAxis()); + myHAxis = new AIS_Axis(xAxis); + myVAxis = new AIS_Axis(yAxis); + myAngularAxis = myVAxis; + myHAxis->SetColor(myAxisColor.Name()); + myVAxis->SetColor(myAxisColor.Name()); + myAngularAxis->SetColor(myAxisColor.Name()); +} + +/*! + fitInResol. + + \param toFit + \param minIsResol +*/ +void Sketch::fitInResol(Standard_Real &toFit, Standard_Boolean minIsResol) +{ + Standard_Real sign = (toFit < 0) ? -1. : +1.; + Standard_Real value = toFit + sign * resol/2.0; /* why "+ resol/2.0" ? because if resol = 0.5, 3.3 is rounded to 3.5 */ + int nTimesResol = int(value/resol); + if ((nTimesResol == 0) && (minIsResol)) nTimesResol = 1; + toFit = nTimesResol*resol; +} + +SketchStatus Sketch::GetCurrentStatus() +{ + return myCurrentStatus; +} + +Standard_Integer Sketch::GetmyEdgesNumber() +{ + return myEdgesNumber; +} + + + diff --git a/src/SKETCHER/GEOM_Sketcher.h b/src/SKETCHER/GEOM_Sketcher.h new file mode 100644 index 000000000..c6c4927e7 --- /dev/null +++ b/src/SKETCHER/GEOM_Sketcher.h @@ -0,0 +1,184 @@ +// File : GEOM_Sketcher.h +// Created : Wed Jul 5 10:12:09 2000 +// Author : Martine LANGLOIS + +// Modified : Tue Dec 11 21:23:41 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "GEOM_SketcherStatus.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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; +}; diff --git a/src/SKETCHER/GEOM_SketcherStatus.h b/src/SKETCHER/GEOM_SketcherStatus.h new file mode 100644 index 000000000..7680391cf --- /dev/null +++ b/src/SKETCHER/GEOM_SketcherStatus.h @@ -0,0 +1,36 @@ +// File : GEOM_SketcherStatus.h +// Created : Wed Jul 5 10:12:09 2000 +// Author : Martine LANGLOIS + +// Modified : Tue Dec 11 21:29:57 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $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 +}; diff --git a/src/SKETCHER/Makefile.in b/src/SKETCHER/Makefile.in new file mode 100644 index 000000000..ba4dccfd7 --- /dev/null +++ b/src/SKETCHER/Makefile.in @@ -0,0 +1,37 @@ +# -* Makefile *- +# +# Author : Patrick GOLDBRONN (CEA) +# Date : 29/06/2001 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:$(srcdir):$(top_srcdir)/idl:$(top_builddir)/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) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += $(OCC_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +# additional file to be cleaned +MOSTLYCLEAN = +CLEAN = +DISTCLEAN = + +@CONCLUDE@ +