/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef _IFC_TUTORIAL_SCHEDULE_CREATION_H_ #define _IFC_TUTORIAL_SCHEDULE_CREATION_H_ #include "ExPrintConsole.h" #include "IIfcTutorial.h" #include "IfcModel.h" #include "Gi/GiWorldDraw.h" #include "Gi/GiSubEntityTraitsData.h" #include #include "IfcGiContext.h" class Tutorial_ScheduleCreation_EntityTraits : public OdGiSubEntityTraits { OdCmEntityColor m_trueColor; OdCmTransparency m_transparency; public: ODRX_DECLARE_MEMBERS(Tutorial_ScheduleCreation_EntityTraits); void setColor(OdUInt16 color) override { } void setTrueColor(const OdCmEntityColor& color) override { m_trueColor = color; } void setTransparency(const OdCmTransparency& transparency) override { m_transparency = transparency; } OdCmTransparency transparency() const override { return m_transparency; } virtual void setLayer(OdDbStub* layerId) override {}; void setLineType(OdDbStub* lineTypeId) override {}; void setSelectionMarker(OdGsMarker selectionMarker) override {}; void setFillType(OdGiFillType fillType) override {}; void setLineWeight(OdDb::LineWeight lineWeight) override {}; void setLineTypeScale(double lineTypeScale = 1.0) override {}; void setThickness(double thickness) override {}; void setPlotStyleName(OdDb::PlotStyleNameType plotStyleNameType, OdDbStub* plotStyleNameId = 0) override {} void setMaterial(OdDbStub* materialId) override {} void setMapper(const OdGiMapper* pMapper) override {} OdUInt16 color() const override { return 0; } OdCmEntityColor trueColor() const override { return m_trueColor; }; OdDbStub* layer() const override { return nullptr; }; OdDbStub* lineType() const override { return nullptr; }; OdGiFillType fillType() const override { return kOdGiFillNever; }; bool fillPlane(OdGeVector3d& normal) override { return true; }; OdDb::LineWeight lineWeight() const override { return OdDb::kLnWt000; }; double lineTypeScale() const override { return 0.; }; double thickness() const override { return 0.; }; OdDb::PlotStyleNameType plotStyleNameType() const override { return OdDb::kPlotStyleNameIsDictDefault; }; OdDbStub* plotStyleNameId() const override { return nullptr; }; OdDbStub* material() const override { return nullptr; } const OdGiMapper* mapper() const override { return nullptr; } void addRef() override {} void release() ODRX_NOEXCEPT override {} }; struct TransformationStack { OdArray m_transfStack; OdGeMatrix3d m_transf; const OdGeMatrix3d& transformation() const { return m_transf; } void pop() { m_transfStack.removeLast(); //update(); } void push(const OdGeMatrix3d& m) { m_transfStack.push_back(m); update(); } void update() { m_transf = OdGeMatrix3d::kIdentity; for (const auto& m : m_transfStack) { m_transf *= m; } } }; struct InstanceContext { OdDAIObjectId m_idIfcProduct; TransformationStack m_transf; OdDAI::ModelPtr m_targetModel; }; class Tutorial_ScheduleCreation_GeomWorldDraw; class Tutorial_ScheduleCreation_WorldGeometry : public OdGiWorldGeometry { public: ODRX_DECLARE_MEMBERS(Tutorial_ScheduleCreation_WorldGeometry); Tutorial_ScheduleCreation_GeomWorldDraw* tutorial_ScheduleCreationWorldDraw() { return reinterpret_cast(m_pWd); } Tutorial_ScheduleCreation_WorldGeometry() : OdGiWorldGeometry() { } /** \details Sets the extents of the current object. \param newExtents [in] Array[2] of WCS points. \remarks Generation of model coordinate geometry automatically calculates the extents. You may override this calculation with this function. */ void setExtents( const OdGePoint3d* newExtents) override { } /** \details Returns the model-to-world coordinate transform matrix for the entity being vectorized. \returns model-to-world transform matrix. \remarks This is the inverse of the matrix returned by getWorldToModelTransform(). If an entity is in one or more blocks, this matrix can be used to determine the WCS coordinates of the entity. */ OdGeMatrix3d getModelToWorldTransform() const override { return OdGeMatrix3d(); } /** \details Returns the world-to-model coordinate transform matrix for the entity being vectorized. \returns world-to-model transform matrix. \remarks This is the inverse of the matrix returned by getModelToWorldTransform(). */ OdGeMatrix3d getWorldToModelTransform() const override { return OdGeMatrix3d(); } /** \details Specifies a model transformation matrix for the current transformation stack. \remarks When a vector is specified, the transformation is created using the arbitrary axis algorithm on the vector. The specified transformation is concatenated to the current model transformation (which is initially the identity transform). The resulting model transformation is subsequently applied to all geometry introduced into this vectorization context, until popModelTransform() is called. \param normal [in] Normal vector. */ void pushModelTransform( const OdGeVector3d& normal) override; /** \details Specifies a model transformation matrix for the current transformation stack. \remarks The specified transformation is concatenated to the current model transformation (which is initially the identity transform). The resulting model transformation is subsequently applied to all geometry introduced into this vectorization context, until popModelTransform() is called. \param xfm [in] Transformation matrix. */ void pushModelTransform( const OdGeMatrix3d& xfm) override; /** \details Removes the top transformation off the current transformation stack. */ void popModelTransform() override; /** \details Introduces a circle to this vectorization context. \remarks The circle is not filled and takes on the current color. If firstPoint, secondPoint, and thirdPoint are specified, they cannot be colinear and no two can be coincident. \param center [in] Center point. \param radius [in] Radius. \param normal [in] Normal. \sa */ void circle( const OdGePoint3d& center, double radius, const OdGeVector3d& normal) override { } /** \details Introduces a circle to this vectorization context. \param firstPoint [in] First point of a 3-point circle. \param secondPoint [in] Second point of a 3-point circle. \param thirdPoint [in] Third point of a 3-point circle. \remarks firstPoint, secondPoint, and thirdPoint cannot be colinear and no two can be coincident. \sa */ void circle( const OdGePoint3d& firstPoint, const OdGePoint3d& secondPoint, const OdGePoint3d& thirdPoint) override { } /** \details Introduces a circular arc to this vectorization context. \param center [in] Center point. \param radius [in] Radius. \param normal [in] Normal vector. \param startVector [in] Start of the arc. \param sweepAngle [in] Angle that defines the arc. \param arcType [in] Arc type. \remarks The arc takes on the current color. All angles are expressed in radians. arcType must be one of the following: Name Value Description kOdGiArcSimple 0 Unfilled. kOdGiArcSector 1 Filled area bounded by the arc and its center. kOdGiArcChord 2 Filled area bounded by the arc and its end points
\sa */ void circularArc( const OdGePoint3d& center, double radius, const OdGeVector3d& normal, const OdGeVector3d& startVector, double sweepAngle, OdGiArcType arcType = kOdGiArcSimple) override { } /** \details Introduces a circular arc to this vectorization context. \param firstPoint [in] First point of a 3-point arc. \param secondPoint [in] Second point of a 3-point arc. \param thirdPoint [in] Third point of a 3-point arc. \param arcType [in] Arc type. \sa */ void circularArc( const OdGePoint3d& firstPoint, const OdGePoint3d& secondPoint, const OdGePoint3d& thirdPoint, OdGiArcType arcType = kOdGiArcSimple) override { } /** \details Introduces a polyline to this vectorization context. \param numVertices [in] Number of vertices. \param vertexList [in] Array of vertices. \param pNormal [in] Pointer to the normal vector. \param baseSubEntMarker [in] Not used. \remarks The polyline is unfilled and takes on the current color and thickness. Use polygon() to render filled areas. The polyline is rendered as a series of lines connecting the first point in vertexList to the second, the second to the third, etc. All points must be coplanar. Use polygon() to render closed areas. \sa */ void polyline( OdInt32 numVertices, const OdGePoint3d* vertexList, const OdGeVector3d* pNormal = 0, OdGsMarker baseSubEntMarker = -1) override; /** \details Introduces a polygon to this vectorization context. \param numVertices [in] Number of vertices. \param vertexList [in] Array of vertices. \remarks The polygon is filled and takes on the current color. Use polyline() to render unfilled areas. The polygon is rendered as a series of lines connecting the first point in vertexList to the second, the second to the third, etc. All points must be coplanar. \sa */ void polygon( OdInt32 numVertices, const OdGePoint3d* vertexList) override { } /** \details Introduces a lightweight polyline into this vectorization context. \param polyline [in] Polyline. \param fromIndex [in] Index of the first segment to be processed. \param numSegs [in] Number of segments to be processed (0 indicates all segments). \remarks The polyline may contain varying segment widths, straight segments and arc segments. The polyline takes on the current color. All points must be coplanar. \sa */ void pline( const OdGiPolyline& polyline, OdUInt32 fromIndex = 0, OdUInt32 numSegs = 0) { } /** \details Introduces a mesh into this vectorization context. \param numRows [in] Number of rows. \param numColumns [in] Number of columns. \param vertexList [in] Array of vertices. \param pEdgeData [in] Pointer to additional edge data. \param pFaceData [in] Pointer to additional face data. \param pVertexData [in] Pointer to additional vertex data. \remarks A mesh is a surface defined by a grid of vertices, and corresponds to a Polygon Mesh. By default, a mesh takes on the current color. Color, linetype, and and other properties can be controlled supplying the appropriate data for the pEdgeData, pFaceData, and pVertexData arguments. \remarks * vertexList must have numRows x numColumns elements. * The arrays in *pEdgeData must be NULL or contain (numRows - 1) x numColumns + numRows x (numColumns -1) elements. * The arrays in *pFaceData must be NULL or contain (numRows - 1) x (numColumns - 1) elements. * The arrays in *pVertexData must be NULL or contain numRows x numColumns elements. \sa */ void mesh( OdInt32 numRows, OdInt32 numColumns, const OdGePoint3d* vertexList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0) override { // Not used } /** \details Introduces a shell into this vectorization context. \param numVertices [in] Number of vertices. \param vertexList [in] Array of vertices. \param faceListSize [in] Number of entries in facesList. \param faceList [in] Array of integers defining faces. \param pEdgeData [in] Pointer to additional edge data. \param pFaceData [in] Pointer to additional face data. \param pVertexData [in] Pointer to additional vertex data. \remarks A shell is a set of faces that can contain holes, and corresponds to a Polyface mesh. By default, a mesh takes on the current color. Color, linetype, and and other properties can be controlled supplying the appropriate data for the pEdgeData, pFaceData, and pVertexData arguments. \remarks * The arrays in *pEdgeData must be NULL or contain the same number of elements as there are edges. * The arrays in *pFaceData must be NULL or contain the same number of elements as there are faces. * The arrays in *pVertexData must be NULL or contain numVertices elements. \sa */ void shell( OdInt32 numVertices, const OdGePoint3d* vertexList, OdInt32 faceListSize, const OdInt32* faceList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0) override; /** \details Introduces text into this vectorization context. \param position [in] Position of the text string. \param normal [in] Normal vector of the text. \param direction [in] Baseline direction of the text. \param height [in] Height of the text. \param width [in] Width factor of the text. \param oblique [in] Oblique angle. \param msg [in] Text string. \remarks The text takes on the current color. If numBytes is not specified, msg must be null terminated. All angles are expressed in radians. As currently implemented, this function ignores width and oblique. They will be fully implemented in a future release. \sa */ void text( const OdGePoint3d& position, const OdGeVector3d& normal, const OdGeVector3d& direction, double height, double width, double oblique, const OdString& msg) override { } /** \details Introduces text into this vectorization context. \param position [in] Position of the text string. \param normal [in] Normal vector of the text. \param direction [in] Baseline direction of the text. \param msg [in] Text string. \param length [in] Number of characters in msg (not including the optional null character). \param raw [in] If and only if true, escape sequences, such as %%P, will not be converted to special characters. \param pTextStyle [in] Pointer to the TextStyle for the text. \sa */ void text( const OdGePoint3d& position, const OdGeVector3d& normal, const OdGeVector3d& direction, const OdChar* msg, OdInt32 length, bool raw, const OdGiTextStyle* pTextStyle) override { } /** \details Introduces an Xline into this vectorization context. \param firstPoint [in] First point. \param secondPoint [in] Second point. \remarks Xlines are infinite lines passing through two points. The xline takes on the current color. \sa */ void xline( const OdGePoint3d& firstPoint, const OdGePoint3d& secondPoint) override { } /** \details Introduces a Ray into this vectorization context. \param basePoint [in] Base point. \param throughPoint [in] Through point. \remarks A Ray is a semi-infinite line that starts at the basePoint, and passes through the throughPoint. The ray takes on the current color. \sa */ void ray( const OdGePoint3d& basePoint, const OdGePoint3d& throughPoint) override { } /** \details Introduces a NURBS curve into this vectorization context. \param nurbsCurve [in] NURBS curve data. \remarks The curve takes on the current color. \sa */ void nurbs( const OdGeNurbCurve3d& nurbsCurve) override { } /** \details Introduces an elliptical arc into this vectorization context. \param ellipArc [in] Elliptical arc. \param endPointsOverrides [in] Array of points to be used as the first and last points of the vectorized arc. \param arcType [in] Arc type. \remarks arcType must be one of the following: Name Value Description kOdGiArcSimple 0 Unfilled. kOdGiArcSector 1 Filled area bounded by the arc and its center. kOdGiArcChord 3 Filled area bounded by the arc and its end points
\sa */ virtual void ellipArc( const OdGeEllipArc3d& ellipArc, const OdGePoint3d* endPointsOverrides = 0, OdGiArcType arcType = kOdGiArcSimple) override { } /** \details Introduces the specified object into this vectorization context. \param pDrawable [in] Pointer to the Drawable object. \remarks Implementations of this method are expected to do the following: * Call OdGiDrawable::subSetAttributes to set attribute information for the object. * Call subWorldDraw on the drawable object to vectorize it into this context. * If subWorldDraw returns false, call subViewportDraw each viewport. */ void draw( const OdGiDrawable* pDrawable) override; /** \details Specifies a clip boundary for the current clip stack. \param pBoundary [in] Pointer to the boundary. \remarks Subsequent objects are clipped until popClipBoundary() is called. \sa */ void pushClipBoundary( OdGiClipBoundary* pBoundary) override { } /** \details Removes the top clip boundary from the clip stack. \sa */ void popClipBoundary() override {} /** \details Introduces a line into this vectorization context. \param points [in] Array of WCS start and end points. \remarks The current model transformation is not applied to the line. \sa */ void worldLine( const OdGePoint3d points[2]) override { } /** \details Inroduces a image in BGRA format into this vectorization context. \param img [in] Image in BGRA format. \param origin [in] Image position in WCS. \param uVec [in] Image width and X-axis orientation. \param vVec [in] Image height and Y-axis orientation. \param trpMode [in] Image transparency processing mode. \sa */ void image( const OdGiImageBGRA32& img, const OdGePoint3d& origin, const OdGeVector3d& uVec, const OdGeVector3d& vVec, OdGiRasterImage::TransparencyMode trpMode = OdGiRasterImage::kTransparency8Bit) override { } /** \details Inroduces a boundary for hatch filling. \param edges [in] Array of 2d curves which represents filling boundary. */ void edge( const OdGiEdge2dArray& edges) override { } void setWordDraw(OdGiWorldDraw* pWd) { m_pWd = pWd; }; const OdDAIObjectIds& getDrawingItems() { return m_drawingObjects; } void setKindOfDrawingItems(const OdAnsiString& kindOf) { m_kindOfDrawingItem = kindOf; } void resetData() { m_drawingObjects.clear(); } void setTargetModel(OdDAI::ModelPtr targetModel) { m_targetModel = targetModel; } const std::multimap& getZOrderedProducts() const { return m_zOrderedProducts; } void clearZOrderedProducts() { m_zOrderedProducts.clear(); } private: OdDAI::ModelPtr m_targetModel; OdAnsiString m_kindOfDrawingItem; OdDAIObjectIds m_drawingObjects; OdGiWorldDraw* m_pWd = nullptr; OdArray m_matrixStack; std::multimap m_zOrderedProducts; std::set m_processedProducts; }; typedef OdSmartPtr Tutorial_ScheduleCreation_WorldGeometryPtr; class Tutorial_ScheduleCreation_GeomWorldDraw : public OdGiWorldDraw { public: ODRX_DECLARE_MEMBERS(Tutorial_ScheduleCreation_GeomWorldDraw); Tutorial_ScheduleCreation_GeomWorldDraw() : OdGiWorldDraw() { m_geometry = Tutorial_ScheduleCreation_WorldGeometry::createObject(); m_geometry->setWordDraw(this); m_ctx = OdGiContextForIfcDatabase::createObject(); } static OdSmartPtr createObject(OdDAI::ModelPtr targetModel) { OdSmartPtr wd = Tutorial_ScheduleCreation_GeomWorldDraw::createObject(); wd->m_targetModel = targetModel; wd->m_geometry->setTargetModel(wd->m_targetModel); return wd; } virtual OdGiWorldGeometry& geometry() const { return *static_cast(const_cast(m_geometry.get()));; } /** \details Retrieves the regeneration type of the current vectorization process. \returns one of the following regeneration types: Name Value eOdGiRegenTypeInvalid 0 kOdGiStandardDisplay 2 kOdGiHideOrShadeCommand 3 kOdGiRenderCommand 4 kOdGiForExplode 5 kOdGiSaveWorldDrawForProxy 6 kOdGiForExtents 7
*/ virtual OdGiRegenType regenType() const { return eOdGiRegenTypeInvalid; } /** \details Checks whether this vectorization process should be aborted. \returns true if this vectorization process should be aborted. */ virtual bool regenAbort() const { return false; } /** \details Provides access to this object's subentity traits. \returns sub-entity traits. \remarks This allows the modification of the vectorization attributes such as color, linetype, etc. */ OdGiSubEntityTraits& subEntityTraits() const override { return m_tutorial_ScheduleCreation_Traits; } /** \details Provides access to this object's "drawing interface." \remarks The "drawing interface" is a set of geometry functions used during the vectorization process. */ virtual OdGiGeometry& rawGeometry() const { return geometry(); }; /** \details Checks whether this vectorization process is the result of a "drag" operation. \returns true if this vectorization process is the result of a "drag" operation, false otherwise. */ virtual bool isDragging() const { return false; }; /** \details Retrieves the recommended maximum deviation of the current vectorization for the specified point on a curve. \param deviationType [in] Deviation type. \param pointOnCurve [in] Point on a curve. \returns recommended maximum difference (with respect to the current active viewport) between the actual curve or surface, and the tessellated curve or surface. \remarks deviationType must be one of the following: Name Value kOdGiMaxDevForCircle 0 kOdGiMaxDevForCurve 1 kOdGiMaxDevForBoundary 2 kOdGiMaxDevForIsoline 3 kOdGiMaxDevForFacet 4
\remarks This method uses circle zoom percent as appropriate. */ virtual double deviation( const OdGiDeviationType deviationType, const OdGePoint3d& pointOnCurve) const { return 0.; } /** \details Retrieves the number of isolines to be drawn on surfaces during this vectorization. \returns number of isolines. \remarks Isolines are lines or curves which are used to represent the entity. For example, if an entity is a sphere and this method returns 3, the sphere should be displayed as 3 circles with a common center and planes that are perpendicular to each other. */ virtual OdUInt32 numberOfIsolines() const { return 0; } /** \details Retrieves context associated with this object. \returns Pointer to the associated context. */ virtual OdGiContext* context() const { return m_ctx; } const OdDAIObjectIds& getDrawingItems() { return m_geometry->getDrawingItems(); } void resetData() { m_geometry->resetData(); } void setKindOfDrawingItems(const OdAnsiString& kindOf) { m_geometry->setKindOfDrawingItems(kindOf); } void setContext(InstanceContext ctx) { m_currentContext = ctx; m_currentContext.m_targetModel = m_targetModel; } InstanceContext& context() { return m_currentContext; } private: InstanceContext m_currentContext; OdDAI::ModelPtr m_targetModel; Tutorial_ScheduleCreation_WorldGeometryPtr m_geometry; mutable Tutorial_ScheduleCreation_EntityTraits m_tutorial_ScheduleCreation_Traits; mutable OdGiContextForIfcDatabasePtr m_ctx; }; typedef OdSmartPtr Tutorial_ScheduleCreation_GeomWorldDrawPtr; class Tutorial_ScheduleCreation : public BaseIfcTutorial { public: Tutorial_ScheduleCreation(const OdString& applicationName); ~Tutorial_ScheduleCreation(); private: int run(const MyServices& svcs, const std::vector& argv, std::ostream& resultStream) override; OdString m_ifcInputFileName; OdString m_ifcOutputFileName; }; #endif // _IFC_TUTORIAL_SCHEDULE_CREATION_H_