One compound shape for curve sections.
#include "CurveCreator_Displayer.h"
#include "CurveCreator_Utils.h"
-#include <AIS_Point.hxx>
-#include <AIS_Line.hxx>
#include <AIS_Shape.hxx>
#include <Geom_CartesianPoint.hxx>
#include <gp_Pnt.hxx>
return theIPnt * myDimension;
}
-std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructSection( int theISection ) const
-{
- std::vector<Handle_AIS_InteractiveObject> aSectionRepresentation;
-
- TopoDS_Shape aShape;
- CurveCreator_Utils::constructShape( this, theISection, aShape, aSectionRepresentation );
-
- AIS_Shape* anAISShape = new AIS_Shape( aShape );
- //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
- aSectionRepresentation.push_back( anAISShape );
-
- return aSectionRepresentation;
-}
-
//=======================================================================
// function: setUndoDepth
// purpose:
return myUndoDepth;
}
-Handle_AIS_Point CurveCreator_Curve::getAISPoint( int theISection, int theIPoint ) const
-{
- double anX, anY, aZ;
- getCoordinates( theISection, theIPoint, anX, anY, aZ );
- gp_Pnt aPoint( anX, anY, aZ);
-
- AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
- return aPnt;
-}
-
-Handle_AIS_Line CurveCreator_Curve::getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const
-{
- double anX, anY, aZ;
- getCoordinates( theISection, theIPoint1, anX, anY, aZ );
- gp_Pnt aPoint1( anX, anY, aZ);
-
- double anX2, anY2, aZ2;
- getCoordinates( theISection, theIPoint2, anX2, anY2, aZ2 );
-//MTN to avoid crash during line construction
- if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){
- aZ2 += 1e-7;
- }
-
- gp_Pnt aPoint2( anX2, anY2, aZ2 );
-
- AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );
- return aLine;
-}
-
void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const
{
CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint );
{
std::vector<Handle_AIS_InteractiveObject> aCurveRepresentation;
-#ifndef ONE_SHAPE
- std::vector<Handle_AIS_InteractiveObject> aSectionObjects;
- for( int iSection = 0 ; iSection < getNbSections() ; iSection++ ){
- aSectionObjects = constructSection( iSection );
- for( int iObject = 0 ; iObject < aSectionObjects.size() ; iObject++ ){
- aCurveRepresentation.push_back( aSectionObjects.at(iObject) );
- }
- }
-#else
TopoDS_Shape aShape;
CurveCreator_Utils::constructShape( this, aShape );
AIS_Shape* anAISShape = new AIS_Shape( aShape );
- //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
aCurveRepresentation.push_back( anAISShape );
-#endif
return aCurveRepresentation;
}
-
-void CurveCreator_Curve::getPoint( const int theISection, const int theIPoint,
- gp_Pnt& thePoint ) const
-{
- double anX, anY, aZ;
- getCoordinates( theISection, theIPoint, anX, anY, aZ );
- thePoint = gp_Pnt( anX, anY, aZ);
-}
#include "CurveCreator_Diff.hxx"
#include "CurveCreator_AISCurve.hxx"
-#include <AIS_Point.hxx>
-#include <AIS_Line.hxx>
#include <AIS_InteractiveObject.hxx>
#include <list>
*/
virtual int toICoord(const int theIPnt) const;
- ListAISObjects constructSection( int theISection ) const;
-
//! For internal use only! Undo/Redo are not used here.
virtual bool moveSectionInternal(const int theISection,
const int theNewIndex);
virtual bool addEmptyDiff();
public: // TODO: remove public
- Handle_AIS_Point getAISPoint( int theISection, int theIPoint ) const;
- Handle_AIS_Line getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const;
void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
protected: // TODO: remove public
void redisplayCurve();
/***********************************************/
virtual ListAISObjects constructWire() const;
-public: // TODO: remove
- void getPoint( const int theSectionId, const int thePointId, gp_Pnt& thePoint ) const;
-
public:
Handle(CurveCreator_AISCurve) myAISCurve;
bool myIsLocked;
return GEOMUtils::ConvertClickToPoint( x, y, aView );
}
-
-//#define USE_COMPOUND
-#include "CurveCreator_Curve.hxx" // TODO - remove
-void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
- const int theISection, TopoDS_Shape& theShape,
- std::vector<Handle_AIS_InteractiveObject>& aSectionRepresentation )
-{
- CurveCreator::SectionType aSectType = theCurve->getSectionType( theISection );
-
-
- int aPointSize = theCurve->getNbPoints( theISection );
- bool aSectIsClosed = theCurve->isClosed( theISection );
- if( aSectType == CurveCreator::Polyline )
- {
-#ifdef USE_COMPOUND
- BRep_Builder aBuilder;
- TopoDS_Compound aComp;
- aBuilder.MakeCompound(aComp);
-
- int iPoint = 0;
- gp_Pnt aPrevPoint, aPoint;
- if ( aPointSize == 1 ) {
- CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPrevPoint );
- TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex( aPrevPoint ).Vertex();
- aBuilder.Add( aComp, aVertex );
- }
- else if ( aPointSize > 1 ) {
- TopoDS_Edge aPointEdge;
- TopoDS_Vertex aVertex;
- CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPrevPoint );
- aVertex = BRepBuilderAPI_MakeVertex( aPrevPoint ).Vertex();
- aBuilder.Add( aComp, aVertex );
- iPoint++;
- for( ; iPoint < aPointSize; iPoint++ ) {
- CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
- aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
- aBuilder.Add( aComp, aVertex );
- aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge();
- aBuilder.Add( aComp, aPointEdge );
- aPrevPoint = aPoint;
- }
- if( aSectIsClosed && ( aPointSize > 2 ) ) {
- CurveCreator_UtilsICurve::getPoint( theCurve, theISection, 0, aPoint );
- aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
- aBuilder.Add( aComp, aVertex );
- aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge();
- aBuilder.Add( aComp, aPointEdge );
- }
- theShape = aComp;
- }
-#endif
- }
- else if( aSectType == CurveCreator::Spline )
- {
- std::vector<double> aPoints;
- for( int iPoint = 0; iPoint < aPointSize; iPoint++ )
- {
- CurveCreator::Coordinates aCoords = theCurve->getPoint( theISection, iPoint );
- double aX = aCoords[0];
- double aY = aCoords[1];
- double aZ = aCoords[2];
- aPoints.push_back( aX );
- aPoints.push_back( aY );
- }
-
- if( aPointSize > 1 )
- {
- Handle(Geom_BSplineCurve) aBSplineCurve;
- // fill array for algorithm by the received coordinates
- int aLen = aPoints.size() / 2;
- Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen);
- std::vector<double>::const_iterator aListIter = aPoints.begin();
- for (int ind = 1; ind <= aLen; ind++) {
- gp_Pnt aPnt(gp::Origin());
- aPnt.SetX(*aListIter);
- aListIter++;
- aPnt.SetY(*aListIter);
- aListIter++;
- aPnt.SetZ(0);
- aHCurvePoints->SetValue(ind, aPnt);
- }
- // compute BSpline
- GeomAPI_Interpolate aGBC(aHCurvePoints, aSectIsClosed, gp::Resolution());
- aGBC.Perform();
- if (aGBC.IsDone()) {
- aBSplineCurve = aGBC.Curve();
- }
- TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSplineCurve ).Edge();
-
- TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
- theShape = aWire;
- }
- }
-
- const CurveCreator_Curve* aCurve = dynamic_cast<const CurveCreator_Curve*>( theCurve );
- if ( !aCurve )
- return;
-
- if( aSectType == CurveCreator::Polyline )
- {
-#ifndef USE_COMPOUND
- int iPoint = 0;
- for( ; iPoint < ( aPointSize - 1 ) ; iPoint++ ){
- Handle_AIS_Point anAISPnt = aCurve->getAISPoint(theISection, iPoint);
- aSectionRepresentation.push_back( anAISPnt );
- Handle_AIS_Line aLine = aCurve->getAISLine( theISection, iPoint, iPoint+1 );
- aSectionRepresentation.push_back( aLine );
- }
- if( aPointSize != 0 ){
- Handle_AIS_Point anAISPnt = aCurve->getAISPoint(theISection, iPoint);
- aSectionRepresentation.push_back( anAISPnt );
- if( aSectIsClosed && ( aPointSize > 1 ) ){
- Handle_AIS_Line aLine = aCurve->getAISLine( theISection, iPoint, 0 );
- aSectionRepresentation.push_back( aLine );
- }
- }
-#endif
- }
- else if( aSectType == CurveCreator::Spline )
- {
- std::vector<double> aPoints;
- for( int iPoint = 0; iPoint < aPointSize; iPoint++ )
- {
- Handle_AIS_Point anAISPnt = aCurve->getAISPoint( theISection, iPoint );
- aSectionRepresentation.push_back( anAISPnt );
- }
- }
-}
-
void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
TopoDS_Shape& theShape )
{
CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y,
Handle(V3d_View) theView );
- /**
- * Generates shape on the curve with a fixed section index
- * \param theCurve a curve object, that contains data
- * \param theISection a curve section index
- * \param theShape a generated shape
- */
- CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
- const int theISection,
- TopoDS_Shape& theShape,
- std::vector<Handle_AIS_InteractiveObject>& theAdditional );
-
/**
* Generates shape on the curve
* \param theCurve a curve object, that contains data