Graphics: add a function contour2dm to be able to make contours on polygonal mesh 08/16208/9
Calixte DENIZET [Sat, 21 Mar 2015 15:03:25 +0000 (16:03 +0100)]
Change-Id: I93d2f5498bea33a756840fd749d80880ea912ba5

18 files changed:
scilab/modules/graphics/Makefile.am
scilab/modules/graphics/Makefile.in
scilab/modules/graphics/graphics.vcxproj
scilab/modules/graphics/graphics.vcxproj.filters
scilab/modules/graphics/help/en_US/2d_plot/contour2d.xml
scilab/modules/graphics/help/en_US/2d_plot/contour2di.xml
scilab/modules/graphics/help/en_US/2d_plot/contour2dm.xml [new file with mode: 0644]
scilab/modules/graphics/includes/gw_graphics.h
scilab/modules/graphics/sci_gateway/c/gw_graphics.c
scilab/modules/graphics/sci_gateway/cpp/sci_contour2dm.cpp [new file with mode: 0644]
scilab/modules/graphics/sci_gateway/graphics_gateway.xml
scilab/modules/graphics/src/cpp/ContourOnMesh.cpp [new file with mode: 0644]
scilab/modules/graphics/src/cpp/ContourOnMesh.hxx [new file with mode: 0644]
scilab/modules/graphics/tests/unit_tests/contour2dm.dia.ref [new file with mode: 0644]
scilab/modules/graphics/tests/unit_tests/contour2dm.tst [new file with mode: 0644]
scilab/modules/helptools/etc/images_md5.txt
scilab/modules/helptools/images/contour2dm_1.png [new file with mode: 0644]
scilab/modules/helptools/images/contour2dm_2.png [new file with mode: 0644]

index 85ea757..40c6204 100644 (file)
@@ -460,9 +460,14 @@ sci_gateway/c/sci_color.c \
 sci_gateway/c/sci_name2rgb.c \
 sci_gateway/c/sci_addcolor.c
 
+GRAPHICS_CXX_SOURCES = src/cpp/ContourOnMesh.cpp
+
+GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_contour2dm.cpp
+
 libscigraphics_la_CPPFLAGS = \
        -I$(srcdir)/includes/ \
        -I$(srcdir)/src/c/ \
+       -I$(srcdir)/src/cpp/ \
        -I$(srcdir)/src/c/getHandleProperty/ \
        -I$(top_srcdir)/modules/action_binding/includes/ \
        -I$(top_srcdir)/modules/api_scilab/includes/ \
@@ -479,7 +484,7 @@ libscigraphics_la_CPPFLAGS = \
        $(AM_CPPFLAGS)
 
 libscigraphics_algo_la_SOURCES = $(GRAPHICS_C_SOURCES) $(GRAPHICS_CXX_SOURCES)
-libscigraphics_la_SOURCES = $(GATEWAY_C_SOURCES)
+libscigraphics_la_SOURCES = $(GATEWAY_C_SOURCES) $(GATEWAY_CXX_SOURCES)
 libscigraphics_algo_la_CPPFLAGS = $(libscigraphics_la_CPPFLAGS)
 
 # For the code check (splint)
index eb67cbf..060b475 100644 (file)
@@ -542,7 +542,8 @@ am__objects_1 = src/c/libscigraphics_algo_la-GetCommandArg.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_auto_margins_property.lo \
        src/c/libscigraphics_algo_la-name2rgb.lo \
        src/c/libscigraphics_algo_la-addColor.lo
-am_libscigraphics_algo_la_OBJECTS = $(am__objects_1)
+am__objects_2 = src/cpp/libscigraphics_algo_la-ContourOnMesh.lo
+am_libscigraphics_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libscigraphics_algo_la_OBJECTS = $(am_libscigraphics_algo_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -555,7 +556,7 @@ am_libscigraphics_disable_la_OBJECTS =  \
 libscigraphics_disable_la_OBJECTS =  \
        $(am_libscigraphics_disable_la_OBJECTS)
 libscigraphics_la_DEPENDENCIES = libscigraphics-algo.la
-am__objects_2 = sci_gateway/c/libscigraphics_la-sci_swap_handles.lo \
+am__objects_3 = sci_gateway/c/libscigraphics_la-sci_swap_handles.lo \
        sci_gateway/c/libscigraphics_la-sci_grayplot.lo \
        sci_gateway/c/libscigraphics_la-sci_matplot1.lo \
        sci_gateway/c/libscigraphics_la-sci_xfpolys.lo \
@@ -618,7 +619,8 @@ am__objects_2 = sci_gateway/c/libscigraphics_la-sci_swap_handles.lo \
        sci_gateway/c/libscigraphics_la-sci_color.lo \
        sci_gateway/c/libscigraphics_la-sci_name2rgb.lo \
        sci_gateway/c/libscigraphics_la-sci_addcolor.lo
-am_libscigraphics_la_OBJECTS = $(am__objects_2)
+am__objects_4 = sci_gateway/cpp/libscigraphics_la-sci_contour2dm.lo
+am_libscigraphics_la_OBJECTS = $(am__objects_3) $(am__objects_4)
 libscigraphics_la_OBJECTS = $(am_libscigraphics_la_OBJECTS)
 @GUI_TRUE@am_libscigraphics_la_rpath = -rpath $(pkglibdir)
 AM_V_P = $(am__v_P_@AM_V@)
@@ -655,6 +657,24 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+       $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
 SOURCES = $(libscigraphics_algo_la_SOURCES) \
        $(libscigraphics_disable_la_SOURCES) \
        $(libscigraphics_la_SOURCES)
@@ -1414,9 +1434,12 @@ sci_gateway/c/sci_color.c \
 sci_gateway/c/sci_name2rgb.c \
 sci_gateway/c/sci_addcolor.c
 
+GRAPHICS_CXX_SOURCES = src/cpp/ContourOnMesh.cpp
+GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_contour2dm.cpp
 libscigraphics_la_CPPFLAGS = \
        -I$(srcdir)/includes/ \
        -I$(srcdir)/src/c/ \
+       -I$(srcdir)/src/cpp/ \
        -I$(srcdir)/src/c/getHandleProperty/ \
        -I$(top_srcdir)/modules/action_binding/includes/ \
        -I$(top_srcdir)/modules/api_scilab/includes/ \
@@ -1433,7 +1456,7 @@ libscigraphics_la_CPPFLAGS = \
        $(AM_CPPFLAGS)
 
 libscigraphics_algo_la_SOURCES = $(GRAPHICS_C_SOURCES) $(GRAPHICS_CXX_SOURCES)
-libscigraphics_la_SOURCES = $(GATEWAY_C_SOURCES)
+libscigraphics_la_SOURCES = $(GATEWAY_C_SOURCES) $(GATEWAY_CXX_SOURCES)
 libscigraphics_algo_la_CPPFLAGS = $(libscigraphics_la_CPPFLAGS)
 
 # For the code check (splint)
@@ -1577,7 +1600,7 @@ HELP_CHAPTERLANG = en_US fr_FR pt_BR
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .sci .bin .c .lo .o .obj
+.SUFFIXES: .sci .bin .c .cpp .lo .o .obj
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.incl.am $(am__configure_deps)
        @for dep in $?; do \
          case '$(am__configure_deps)' in \
@@ -2743,9 +2766,17 @@ src/c/libscigraphics_algo_la-name2rgb.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
 src/c/libscigraphics_algo_la-addColor.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
+src/cpp/$(am__dirstamp):
+       @$(MKDIR_P) src/cpp
+       @: > src/cpp/$(am__dirstamp)
+src/cpp/$(DEPDIR)/$(am__dirstamp):
+       @$(MKDIR_P) src/cpp/$(DEPDIR)
+       @: > src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libscigraphics_algo_la-ContourOnMesh.lo:  \
+       src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscigraphics-algo.la: $(libscigraphics_algo_la_OBJECTS) $(libscigraphics_algo_la_DEPENDENCIES) $(EXTRA_libscigraphics_algo_la_DEPENDENCIES) 
-       $(AM_V_CCLD)$(LINK) $(am_libscigraphics_algo_la_rpath) $(libscigraphics_algo_la_OBJECTS) $(libscigraphics_algo_la_LIBADD) $(LIBS)
+       $(AM_V_CXXLD)$(CXXLINK) $(am_libscigraphics_algo_la_rpath) $(libscigraphics_algo_la_OBJECTS) $(libscigraphics_algo_la_LIBADD) $(LIBS)
 src/nographics/$(am__dirstamp):
        @$(MKDIR_P) src/nographics
        @: > src/nographics/$(am__dirstamp)
@@ -2953,18 +2984,31 @@ sci_gateway/c/libscigraphics_la-sci_name2rgb.lo:  \
 sci_gateway/c/libscigraphics_la-sci_addcolor.lo:  \
        sci_gateway/c/$(am__dirstamp) \
        sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/$(am__dirstamp):
+       @$(MKDIR_P) sci_gateway/cpp
+       @: > sci_gateway/cpp/$(am__dirstamp)
+sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp):
+       @$(MKDIR_P) sci_gateway/cpp/$(DEPDIR)
+       @: > sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscigraphics_la-sci_contour2dm.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscigraphics.la: $(libscigraphics_la_OBJECTS) $(libscigraphics_la_DEPENDENCIES) $(EXTRA_libscigraphics_la_DEPENDENCIES) 
-       $(AM_V_CCLD)$(LINK) $(am_libscigraphics_la_rpath) $(libscigraphics_la_OBJECTS) $(libscigraphics_la_LIBADD) $(LIBS)
+       $(AM_V_CXXLD)$(CXXLINK) $(am_libscigraphics_la_rpath) $(libscigraphics_la_OBJECTS) $(libscigraphics_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
        -rm -f *.$(OBJEXT)
        -rm -f sci_gateway/c/*.$(OBJEXT)
        -rm -f sci_gateway/c/*.lo
+       -rm -f sci_gateway/cpp/*.$(OBJEXT)
+       -rm -f sci_gateway/cpp/*.lo
        -rm -f src/c/*.$(OBJEXT)
        -rm -f src/c/*.lo
        -rm -f src/c/getHandleProperty/*.$(OBJEXT)
        -rm -f src/c/getHandleProperty/*.lo
+       -rm -f src/cpp/*.$(OBJEXT)
+       -rm -f src/cpp/*.lo
        -rm -f src/nographics/*.$(OBJEXT)
        -rm -f src/nographics/*.lo
 
@@ -3034,6 +3078,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscigraphics_la-sci_xstringb.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscigraphics_la-sci_xtitle.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscigraphics_la-sci_zoom_rect.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigraphics_la-sci_contour2dm.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-Axes.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-BasicAlgos.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-BuildObjects.Plo@am__quote@
@@ -3404,6 +3449,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_z_ticks_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_zoom_box_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_zoom_state_property.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphics_algo_la-ContourOnMesh.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/nographics/$(DEPDIR)/libscigraphics_disable_la-nographics.Plo@am__quote@
 
 .c.o:
@@ -6468,14 +6514,54 @@ sci_gateway/c/libscigraphics_la-sci_addcolor.lo: sci_gateway/c/sci_addcolor.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscigraphics_la-sci_addcolor.lo `test -f 'sci_gateway/c/sci_addcolor.c' || echo '$(srcdir)/'`sci_gateway/c/sci_addcolor.c
 
+.cpp.o:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCXX_TRUE@  $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCXX_TRUE@  $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCXX_TRUE@  $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCXX_TRUE@  $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
+
+src/cpp/libscigraphics_algo_la-ContourOnMesh.lo: src/cpp/ContourOnMesh.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscigraphics_algo_la-ContourOnMesh.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscigraphics_algo_la-ContourOnMesh.Tpo -c -o src/cpp/libscigraphics_algo_la-ContourOnMesh.lo `test -f 'src/cpp/ContourOnMesh.cpp' || echo '$(srcdir)/'`src/cpp/ContourOnMesh.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscigraphics_algo_la-ContourOnMesh.Tpo src/cpp/$(DEPDIR)/libscigraphics_algo_la-ContourOnMesh.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/ContourOnMesh.cpp' object='src/cpp/libscigraphics_algo_la-ContourOnMesh.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscigraphics_algo_la-ContourOnMesh.lo `test -f 'src/cpp/ContourOnMesh.cpp' || echo '$(srcdir)/'`src/cpp/ContourOnMesh.cpp
+
+sci_gateway/cpp/libscigraphics_la-sci_contour2dm.lo: sci_gateway/cpp/sci_contour2dm.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscigraphics_la-sci_contour2dm.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscigraphics_la-sci_contour2dm.Tpo -c -o sci_gateway/cpp/libscigraphics_la-sci_contour2dm.lo `test -f 'sci_gateway/cpp/sci_contour2dm.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_contour2dm.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscigraphics_la-sci_contour2dm.Tpo sci_gateway/cpp/$(DEPDIR)/libscigraphics_la-sci_contour2dm.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_contour2dm.cpp' object='sci_gateway/cpp/libscigraphics_la-sci_contour2dm.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscigraphics_la-sci_contour2dm.lo `test -f 'sci_gateway/cpp/sci_contour2dm.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_contour2dm.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
 clean-libtool:
        -rm -rf .libs _libs
        -rm -rf sci_gateway/c/.libs sci_gateway/c/_libs
+       -rm -rf sci_gateway/cpp/.libs sci_gateway/cpp/_libs
        -rm -rf src/c/.libs src/c/_libs
        -rm -rf src/c/getHandleProperty/.libs src/c/getHandleProperty/_libs
+       -rm -rf src/cpp/.libs src/cpp/_libs
        -rm -rf src/nographics/.libs src/nographics/_libs
 install-libscigraphics_la_etcDATA: $(libscigraphics_la_etc_DATA)
        @$(NORMAL_INSTALL)
@@ -6683,10 +6769,14 @@ distclean-generic:
        -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
        -rm -f sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
        -rm -f sci_gateway/c/$(am__dirstamp)
+       -rm -f sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+       -rm -f sci_gateway/cpp/$(am__dirstamp)
        -rm -f src/c/$(DEPDIR)/$(am__dirstamp)
        -rm -f src/c/$(am__dirstamp)
        -rm -f src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
        -rm -f src/c/getHandleProperty/$(am__dirstamp)
+       -rm -f src/cpp/$(DEPDIR)/$(am__dirstamp)
+       -rm -f src/cpp/$(am__dirstamp)
        -rm -f src/nographics/$(DEPDIR)/$(am__dirstamp)
        -rm -f src/nographics/$(am__dirstamp)
 
@@ -6699,7 +6789,7 @@ clean-am: clean-generic clean-libtool clean-local \
        clean-noinstLTLIBRARIES clean-pkglibLTLIBRARIES mostlyclean-am
 
 distclean: distclean-am
-       -rm -rf sci_gateway/c/$(DEPDIR) src/c/$(DEPDIR) src/c/getHandleProperty/$(DEPDIR) src/nographics/$(DEPDIR)
+       -rm -rf sci_gateway/c/$(DEPDIR) sci_gateway/cpp/$(DEPDIR) src/c/$(DEPDIR) src/c/getHandleProperty/$(DEPDIR) src/cpp/$(DEPDIR) src/nographics/$(DEPDIR)
        -rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
        distclean-local distclean-tags
@@ -6748,7 +6838,7 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-       -rm -rf sci_gateway/c/$(DEPDIR) src/c/$(DEPDIR) src/c/getHandleProperty/$(DEPDIR) src/nographics/$(DEPDIR)
+       -rm -rf sci_gateway/c/$(DEPDIR) sci_gateway/cpp/$(DEPDIR) src/c/$(DEPDIR) src/c/getHandleProperty/$(DEPDIR) src/cpp/$(DEPDIR) src/nographics/$(DEPDIR)
        -rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
index b553ebb..3ab4946 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
@@ -135,7 +135,7 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
-      <AdditionalIncludeDirectories>includes/handleDrawing;includes;src/c;src/c/getHandleProperty;../../java/jdk/include;../../java/jdk/include/win32;../elementary_functions/includes;../output_stream/includes;../fileio/includes;../gui/includes;../core/includes;../graphic_objects/includes;../localization/includes;../renderer/includes;../jvm/includes;../action_binding/includes;../graphic_export/includes;../string/includes;../windows_tools/includes;../api_scilab/includes;../../libs/intl;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>includes/handleDrawing;includes;src/cpp;src/c;src/c/getHandleProperty;../../java/jdk/include;../../java/jdk/include/win32;../elementary_functions/includes;../output_stream/includes;../fileio/includes;../gui/includes;../core/includes;../graphic_objects/includes;../localization/includes;../renderer/includes;../jvm/includes;../action_binding/includes;../graphic_export/includes;../string/includes;../windows_tools/includes;../api_scilab/includes;../../libs/intl;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>FORDLL;NDEBUG;_WINDOWS;_USRDLL;GRAPHICS_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -198,10 +198,12 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="sci_gateway\cpp\sci_contour2dm.cpp" />
     <ClCompile Include="sci_gateway\c\sci_addcolor.c" />
     <ClCompile Include="sci_gateway\c\sci_color.c" />
     <ClCompile Include="sci_gateway\c\sci_light.c" />
     <ClCompile Include="sci_gateway\c\sci_name2rgb.c" />
+    <ClCompile Include="src\cpp\ContourOnMesh.cpp" />
     <ClCompile Include="src\c\addColor.c" />
     <ClCompile Include="src\c\Axes.c" />
     <ClCompile Include="src\c\axesScale.c" />
@@ -749,4 +751,4 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
index ff15c59..4e09583 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
     <Filter Include="Source Files">
     <ClCompile Include="sci_gateway\c\sci_color.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_contour2dm.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\ContourOnMesh.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\Axes.h">
       <Filter>Resource Files</Filter>
     </ResourceCompile>
   </ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
index b57fed1..ffe76a8 100644 (file)
@@ -217,6 +217,9 @@ xtitle("Some level curves of the function cos(x)cos(y)")
                 <link linkend="contour2di">contour2di</link>
             </member>
             <member>
+                <link linkend="contour2dm">contour2dm</link>
+            </member>
+            <member>
                 <link linkend="plot2d">plot2d</link>
             </member>
         </simplelist>
index a72d5d5..a3cdbdd 100644 (file)
@@ -137,6 +137,9 @@ end
                 <link linkend="contour2d">contour2d</link>
             </member>
             <member>
+                <link linkend="contour2dm">contour2dm</link>
+            </member>
+            <member>
                 <link linkend="plot2d">plot2d</link>
             </member>
         </simplelist>
diff --git a/scilab/modules/graphics/help/en_US/2d_plot/contour2dm.xml b/scilab/modules/graphics/help/en_US/2d_plot/contour2dm.xml
new file mode 100644 (file)
index 0000000..22470e5
--- /dev/null
@@ -0,0 +1,335 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) Scilab Enterprises 
+ * 
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at    
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"  xml:lang="en" xml:id="contour2dm">
+    <refnamediv>
+        <refname>contour2dm</refname>
+        <refpurpose>compute level curves of a surface defined with a mesh</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>[xc, yc] = contour2dm(x, y, polygons, func, nz)</synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>x, y</term>
+                <listitem>
+                    <para>
+                        two vectors of size <literal>n</literal>, <literal>(x(i),y(i))</literal> gives the coordinates of 
+                        node  <literal>i</literal>.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>polygons</term>
+                <listitem>
+                    <para>
+                        is a <literal>[Ntr,N+2]</literal> matrix. Each line of <varname>polygons</varname> specifies a convex polygon 
+                        of the  mesh <literal>polygons(j) = [number,node1,node2,node3, ..., nodeN, flag]</literal>. 
+                        <literal>node1,node2,node3, ..., nodeN</literal> are the number of the nodes which constitutes 
+                        the polygon. number is the number of the polygons and flag is an integer 
+                        not used in the <function>contour2dm</function> function.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>func</term>
+                <listitem>
+                    <para>
+                        a vector of size <literal>n</literal> : <literal>func(i)</literal> gives the value at node <literal>i</literal>
+                        of the function.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>nz</term>
+                <listitem>
+                    <para>
+                        the level values or the number of levels.
+                    </para>
+                    <variablelist>
+                        <varlistentry>
+                            <term>
+                                If <literal>nz</literal> is an integer
+                            </term>
+                            <listitem>
+                                <para>
+                                    its value gives the number of
+                                    level curves  equally spaced from <literal>zmin</literal> to <literal>zmax</literal> as follows:
+                                </para>
+                                <programlisting role="no-scilab-exec"><![CDATA[ 
+z= zmin + (1:nz)*(zmax-zmin)/(nz+1)
+ ]]></programlisting>
+                             </listitem>
+                        </varlistentry>
+                        <varlistentry>
+                            <term>
+                                If <literal>nz</literal> is a vector
+                            </term>
+                            <listitem>
+                                <para>
+                                    <literal>nz(i)</literal> gives the value of
+                                    the <literal>i</literal>-th level curve.
+                                </para>
+                            </listitem>
+                        </varlistentry>
+                    </variablelist>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>xc, yc</term>
+                <listitem>
+                    <para>
+                        vectors of identical sizes containing the contours definitions. See below for details.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>
+            <function>contour2dm</function> computes level curves of a surface
+            <literal>z = f(x, y)</literal> on a 2D plot.  The values of
+            <literal>f(x,y)</literal> are given by the matrix <varname>z</varname>
+            at the points of the mesh defined by <varname>x</varname> and <varname>y</varname>.
+        </para>
+        <para>
+            <literal>xc(1)</literal> contains the level associated with first
+            contour path, <literal>yc(1)</literal> contains the number
+            <literal>N1</literal> of points defining this contour path and
+            (<literal>xc(1+(1:N1))</literal>, <literal>yc(1+(1:N1))</literal> )
+            contain the coordinates of the paths points. The second path begin
+            at <literal>xc(2+N1)</literal> and <literal>yc(2+N1)</literal> and
+            so on.
+        </para>
+        <para>
+            Note that some loops can appear on a level curve when some vertexes of polygons as the same value as the level one. See example #2
+        </para>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[ 
+m = [6 5 4; ...
+           6 2 5; ...
+           6 4 1; ...
+           5 2 3];
+
+nodes = [55  20; ...
+          85  5; ...
+          100 10; ...
+          75  30; ...
+          80  20; ...
+          70  15];
+z_fec = [-1 -1 0 0 1 1];
+
+f = scf();
+f.color_map = jetcolormap(12);
+fec(nodes(:, 1), nodes(:, 2), [(1:size(m, 1))', m, (1:size(m, 1))'], z_fec);
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z_fec, [-0.5, 0, 0.5]);
+k=1;n=yc(k);c=1;
+N = size(xc, '*')
+while k <= N & k+yc(k)<=N
+  n=yc(k);
+  plot2d(xc(k+(1:n)),yc(k+(1:n)));
+  c=c+1;
+  k=k+n+1;
+end
+ ]]></programlisting>
+        <scilab:image>
+        m = [6 5 4; ...
+                   6 2 5; ...
+                   6 4 1; ...
+                   5 2 3];
+
+        nodes = [55  20; ...
+                  85  5; ...
+                  100 10; ...
+                  75  30; ...
+                  80  20; ...
+                  70  15];
+        z_fec = [-1 -1 0 0 1 1];
+
+        f = scf();
+        f.color_map = jetcolormap(12);
+        fec(nodes(:, 1), nodes(:, 2), [(1:size(m, 1))', m, (1:size(m, 1))'], z_fec);
+        [xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z_fec, [-0.5, 0, 0.5]);
+        k=1;n=yc(k);c=1;
+        N = size(xc, '*');
+        while k &lt;= N &amp; k+yc(k) &lt;=N
+          n=yc(k);
+          plot2d(xc(k+(1:n)),yc(k+(1:n)))
+          c=c+1;
+          k=k+n+1;
+        end
+        </scilab:image>
+        <programlisting role="example"><![CDATA[
+f=scf();
+f.color_map = jetcolormap(3);
+m = [1  2  3; ...
+     1  3  4; ...
+     3  4  5; ...
+     6  2  3; ...
+     7  6  3; ...
+     7  3  5; ...
+     7  5  8; ...
+     2  9  6; ...
+     9  6  10; ...
+     6  7  10; ...
+     10 11 7; ...
+     7  8  12; ...
+     9  10 13; ...
+     7  10 11; ...
+     7  12 11; ...
+     13 10 14; ...
+     10 11 14; ...
+     11 14 15; ...
+     11 12 15];
+
+nodes = [0  50; ... //1
+         20 60; ... //2
+         15 40; ... //3
+         0  30; ... //4
+         20 20; ... //5
+         30 45; ... //6
+         27 25; ... //7
+         26 10; ... //8
+         35 65; ... //9
+         40 42; ... //10
+         45 30; ... //11
+         42 15; ... //12
+         50 62; ... //13
+         55 40; ... //14
+         53 17]; //15
+
+z = [0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 2, 2, 2];
+
+nb_mesh = [(1:size(m, 1))', m, (1:size(m, 1))'];
+fec(nodes(:, 1), nodes(:, 2), nb_mesh, z, mesh=%t);
+e=gce();
+e.children.foreground = -2;
+
+// Contour2dm
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), nb_mesh, z, linspace(0,3,4));
+k=1;n=yc(k);c=1;
+N = size(xc, '*');
+while k <= N & k+yc(k)<=N
+    n=yc(k);
+    plot2d(xc(k+(1:n)),yc(k+(1:n)));
+    e=gce();
+    e.children.foreground = -1;
+    c=c+1;
+    k=k+n+1;
+end
+// Here we have a loop in the green part because each vertex on this level curve is equal to 1.
+// To be clearer, let us change the color_map
+f.color_map = jetcolormap(1024);
+ ]]></programlisting>
+        <scilab:image>
+            f=scf();
+            f.color_map = jetcolormap(3);
+            m = [1  2  3; ...
+                 1  3  4; ...
+                 3  4  5; ...
+                 6  2  3; ...
+                 7  6  3; ...
+                 7  3  5; ...
+                 7  5  8; ...
+                 2  9  6; ...
+                 9  6  10; ...
+                 6  7  10; ...
+                 10 11 7; ...
+                 7  8  12; ...
+                 9  10 13; ...
+                 7  10 11; ...
+                 7  12 11; ...
+                 13 10 14; ...
+                 10 11 14; ...
+                 11 14 15; ...
+                 11 12 15];
+
+            nodes = [0  50; ... //1
+                     20 60; ... //2
+                     15 40; ... //3
+                     0  30; ... //4
+                     20 20; ... //5
+                     30 45; ... //6
+                     27 25; ... //7
+                     26 10; ... //8
+                     35 65; ... //9
+                     40 42; ... //10
+                     45 30; ... //11
+                     42 15; ... //12
+                     50 62; ... //13
+                     55 40; ... //14
+                     53 17]; //15
+
+            z = [0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 2, 2, 2];
+
+            nb_mesh = [(1:size(m, 1))', m, (1:size(m, 1))'];
+            fec(nodes(:, 1), nodes(:, 2), nb_mesh, z, mesh=%t);
+            e=gce();
+            e.children.foreground = -2;
+
+            // Contour2dm
+            [xc, yc] = contour2dm(nodes(:,1), nodes(:,2), nb_mesh, z, linspace(0,3,4));
+            k=1;n=yc(k);c=1;
+            N = size(xc, '*');
+            while k &lt;= N &amp; k+yc(k) &lt;= N
+                n=yc(k);
+                plot2d(xc(k+(1:n)),yc(k+(1:n)));
+                e=gce();
+                e.children.foreground = -1;
+                c=c+1;
+                k=k+n+1;
+            end
+            // Here we have a loop in the green part because each vertex on this level curve is equal to 1.
+            // To be clearer, let us change the color_map
+            f.color_map = jetcolormap(1024);
+        </scilab:image>
+    </refsection>
+    <refsection role="see also">
+        <title>See Also</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="contour2di">contour2di</link>
+            </member>
+            <member>
+                <link linkend="contour2d">contour2d</link>
+            </member>
+            <member>
+                <link linkend="contour">contour</link>
+            </member>
+            <member>
+                <link linkend="fec">fec</link>
+            </member>
+            <member>
+                <link linkend="plot2d">plot2d</link>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.2</revnumber>
+                <revremark>
+                    <para>
+                        Function contour2dm introduced.
+                    </para>
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
index 0b22d9b..301fc14 100644 (file)
@@ -98,6 +98,7 @@ GRAPHICS_IMPEXP int sci_light(char *fname, unsigned long fname_len);
 GRAPHICS_IMPEXP int sci_addcolor(char *fname, unsigned long fname_len);
 GRAPHICS_IMPEXP int sci_name2rgb(char *fname, unsigned long fname_len);
 GRAPHICS_IMPEXP int sci_color(char *fname, unsigned long fname_len);
+GRAPHICS_IMPEXP int sci_contour2dm(char *fname, unsigned long fname_len);
 
 /*--------------------------------------------------------------------------*/
 #endif /* __INTGRAPHICS__ */
index 400dfa6..0985308 100644 (file)
@@ -94,7 +94,8 @@ static gw_generic_table Tab[] =
     {sci_light, "light"},
     {sci_addcolor, "addcolor"},
     {sci_name2rgb, "name2rgb"},
-    {sci_color, "color"}
+    {sci_color, "color"},
+    {sci_contour2dm, "contour2dm"}
 };
 
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/graphics/sci_gateway/cpp/sci_contour2dm.cpp b/scilab/modules/graphics/sci_gateway/cpp/sci_contour2dm.cpp
new file mode 100644 (file)
index 0000000..139a0ce
--- /dev/null
@@ -0,0 +1,232 @@
+#include "ContourOnMesh.hxx"
+
+extern "C"
+{
+#include "gw_graphics.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "math_graphics.h"
+}
+
+int sci_contour2dm(char * fname, unsigned long fname_len)
+{
+    SciErr sciErr;
+    int m1 = 0, n1 = 0, m2 = 0, n2 = 0, m3 = 0, n3 = 0, m4 = 0, n4 = 0, m5 = 0, n5 = 0, mn1 = 0;
+    int iType1 = 0, iType2 = 0, iType3 = 0, iType4 = 0, iType5 = 0;
+
+    int* piAddr1 = NULL;
+    int* piAddr2 = NULL;
+    int* piAddr3 = NULL;
+    int* piAddr4 = NULL;
+    int* piAddr5 = NULL;
+
+    double* l1 = NULL;
+    double* l2 = NULL;
+    double* l3 = NULL;
+    double* l4 = NULL;
+    double* l5 = NULL;
+
+    bool l5alloc = false;
+
+    std::vector<double> xC;
+    std::vector<double> yC;
+
+    CheckInputArgument(pvApiCtx, 5, 5);
+    CheckOutputArgument(pvApiCtx, 2, 2);
+
+    //get variable address
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 1;
+    }
+    //check type
+    sciErr = getVarType(pvApiCtx, piAddr1, &iType1);
+    if (sciErr.iErr || iType1 != sci_matrix)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
+        printError(&sciErr, 0);
+        return 1;
+    }
+    // Retrieve a matrix of double at position 1.
+    sciErr = getMatrixOfDouble(pvApiCtx, piAddr1, &m1, &n1, &l1);
+    if (sciErr.iErr)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    //get variable address
+    sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 1;
+    }
+    //check type
+    sciErr = getVarType(pvApiCtx, piAddr2, &iType2);
+    if (sciErr.iErr || iType2 != sci_matrix)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 2);
+        printError(&sciErr, 0);
+        return 1;
+    }
+    // Retrieve a matrix of double at position 2.
+    sciErr = getMatrixOfDouble(pvApiCtx, piAddr2, &m2, &n2, &l2);
+    if (sciErr.iErr)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 2);
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    //CheckSameDims
+    if (m1 != m2 || n1 != n2)
+    {
+        Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 2, m1, n1);
+        return 1;
+    }
+
+    //get variable address
+    sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 1;
+    }
+    //check type
+    sciErr = getVarType(pvApiCtx, piAddr3, &iType3);
+    if (sciErr.iErr || iType3 != sci_matrix)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 3);
+        printError(&sciErr, 0);
+        return 1;
+    }
+    // Retrieve a matrix of double at position 3.
+    sciErr = getMatrixOfDouble(pvApiCtx, piAddr3, &m3, &n3, &l3);
+    if (sciErr.iErr)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 3);
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    if (n3 < 5)
+    {
+        Scierror(999, _("%s: Wrong number of columns for input argument #%d: at least %d expected.\n"), fname, 3, 5);
+        return 0;
+    }
+
+    // remove number and flag
+    n3 -= 2;
+
+    //get variable address
+    sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddr4);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 1;
+    }
+    //check type
+    sciErr = getVarType(pvApiCtx, piAddr4, &iType4);
+    if (sciErr.iErr || iType4 != sci_matrix)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 4);
+        printError(&sciErr, 0);
+        return 1;
+    }
+    // Retrieve a matrix of double at position 4.
+    sciErr = getMatrixOfDouble(pvApiCtx, piAddr4, &m4, &n4, &l4);
+    if (sciErr.iErr)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 4);
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 5, &piAddr5);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 1;
+    }
+    //check type
+    sciErr = getVarType(pvApiCtx, piAddr5, &iType5);
+    if (sciErr.iErr || iType5 != sci_matrix)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 5);
+        printError(&sciErr, 0);
+        return 1;
+    }
+    // Retrieve a matrix of double at position 5.
+    sciErr = getMatrixOfDouble(pvApiCtx, piAddr5, &m5, &n5, &l5);
+    if (sciErr.iErr)
+    {
+        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 5);
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    if (m1 * n1 == 0 || m3 == 0)
+    {
+        AssignOutputVariable(pvApiCtx, 1) = 0;
+        ReturnArguments(pvApiCtx);
+        return 0;
+    }
+
+    // If z is a scalar
+    if (m5 * n5 == 1)
+    {
+        double zmin = (double) Mini(l4, m4 * n4);
+        double zmax = (double) Maxi(l4, m4 * n4);
+        int nb = l5[0];
+        l5 = new double[nb];
+        l5alloc = true;
+        for (int i = 0; i < nb; ++i)
+        {
+            l5[i] = zmin + (i + 1) * (zmax - zmin) / (nb + 1);
+        }
+        m5 = 1;
+        n5 = nb;
+    }
+
+    bool res = org_modules_graphics::LevelCurve::compute(m1 * n1, l1, l2, l4, m3, n3, l3, m5 * n5, l5, xC, yC);
+    if (l5alloc)
+    {
+        delete[] l5;
+    }
+
+    if (!res)
+    {
+        // error in index
+        Scierror(999, _("%s: Invalid vertex index.\n"), fname, 3);
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    sciErr = createMatrixOfDouble(pvApiCtx, 6, 1, xC.size(), &(xC[0]));
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 1;
+    }
+
+    sciErr = createMatrixOfDouble(pvApiCtx, 7, 1, yC.size(), &(yC[0]));
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 1;
+    }
+
+    AssignOutputVariable(pvApiCtx, 1) = 6;
+    AssignOutputVariable(pvApiCtx, 2) = 7;
+    ReturnArguments(pvApiCtx);
+
+    return 0;
+
+}
index 3382f0f..1410919 100644 (file)
@@ -90,4 +90,5 @@
     <PRIMITIVE gatewayId="7" primitiveId="66" primitiveName="addcolor"/>
     <PRIMITIVE gatewayId="7" primitiveId="67" primitiveName="name2rgb"/>
     <PRIMITIVE gatewayId="7" primitiveId="68" primitiveName="color"/>
+    <PRIMITIVE gatewayId="7" primitiveId="69" primitiveName="contour2dm"/>
 </GATEWAY>
diff --git a/scilab/modules/graphics/src/cpp/ContourOnMesh.cpp b/scilab/modules/graphics/src/cpp/ContourOnMesh.cpp
new file mode 100644 (file)
index 0000000..651a35e
--- /dev/null
@@ -0,0 +1,319 @@
+#include "ContourOnMesh.hxx"
+
+namespace org_modules_graphics
+{
+
+void Line::add(const std::vector<Point2D> & pts)
+{
+    if (points.back() == pts.front())
+    {
+        points.push_back(pts.back());
+    }
+    else if (points.back() == pts.back())
+    {
+        points.push_back(pts.front());
+    }
+    else if (points.front() == pts.back())
+    {
+        points.insert(points.begin(), pts.front());
+    }
+    else if (points.front() == pts.front())
+    {
+        points.insert(points.begin(), pts.back());
+    }
+}
+
+void Line::add(Line * line)
+{
+    if (points.back() == line->points.front())
+    {
+        points.insert(points.end(), ++line->points.begin(), line->points.end());
+    }
+    else if (points.back() == line->points.back())
+    {
+        points.insert(points.end(), ++line->points.rbegin(), line->points.rend());
+    }
+    else if (points.front() == line->points.back())
+    {
+        points.insert(points.begin(), line->points.begin(), --line->points.end());
+    }
+    else if (points.front() == line->points.front())
+    {
+        points.insert(points.begin(), line->points.rbegin(), --line->points.rend());
+    }
+}
+
+void LevelCurve::intersect(const Point3D & A, const Point3D & B, const Point3D & C)
+{
+    if (A.z == zi && B.z == zi && C.z == zi)
+    {
+        return;
+    }
+
+    if (A.z == zi)
+    {
+        pts.push_back(Point2D(A.x, A.y));
+        edges.push_back(Edge(A.index, A.index));
+    }
+
+    if (B.z == zi)
+    {
+        pts.push_back(Point2D(B.x, B.y));
+        edges.push_back(Edge(B.index, B.index));
+    }
+
+    if (C.z == zi)
+    {
+        pts.push_back(Point2D(C.x, C.y));
+        edges.push_back(Edge(C.index, C.index));
+    }
+
+    if (pts.size() == 2)
+    {
+        Edge e(edges.front().v1, edges.back().v1);
+        if (common.find(e) == common.end())
+        {
+            common.insert(e);
+        }
+        else
+        {
+            clear();
+            // already treated
+            return;
+        }
+    }
+    else
+    {
+        // check the intersection with [AB] and z=zi
+        if ((A.z < zi && zi < B.z) || (B.z < zi && zi < A.z))
+        {
+            if (A.index < B.index)
+            {
+                const double t = (zi - A.z) / (B.z - A.z);
+                pts.push_back(Point2D(A.x + t * (B.x - A.x), A.y + t * (B.y - A.y)));
+                edges.push_back(Edge(A.index, B.index));
+            }
+            else
+            {
+                const double t = (zi - B.z) / (A.z - B.z);
+                pts.push_back(Point2D(B.x + t * (A.x - B.x), B.y + t * (A.y - B.y)));
+                edges.push_back(Edge(B.index, A.index));
+            }
+        }
+
+        // check the intersection with [BC] and z=zi
+        if (pts.size() != 2 && ((B.z < zi && zi < C.z) || (C.z < zi && zi < B.z)))
+        {
+            if (B.index < C.index)
+            {
+                const double t = (zi - B.z) / (C.z - B.z);
+                const Point2D p(B.x + t * (C.x - B.x), B.y + t * (C.y - B.y));
+                pts.push_back(p);
+                edges.push_back(Edge(B.index, C.index));
+            }
+            else
+            {
+                const double t = (zi - C.z) / (B.z - C.z);
+                const Point2D p(C.x + t * (B.x - C.x), C.y + t * (B.y - C.y));
+                pts.push_back(p);
+                edges.push_back(Edge(C.index, B.index));
+            }
+        }
+
+        // check the intersection with [CA] and z=zi
+        if (!pts.empty() && pts.size() != 2 && ((C.z < zi && zi < A.z) || (A.z < zi && zi < C.z)))
+        {
+            if (C.index < A.index)
+            {
+                const double t = (zi - C.z) / (A.z - C.z);
+                const Point2D p(C.x + t * (A.x - C.x), C.y + t * (A.y - C.y));
+                pts.push_back(p);
+                edges.push_back(Edge(C.index, A.index));
+            }
+            else
+            {
+                const double t = (zi - A.z) / (C.z - A.z);
+                const Point2D p(A.x + t * (C.x - A.x), A.y + t * (C.y - A.y));
+                pts.push_back(p);
+                edges.push_back(Edge(A.index, C.index));
+            }
+        }
+    }
+
+    if (pts.size() == 2 && pts.back() != pts.front())
+    {
+        // we have a segment
+        Edge & e1 = edges.front();
+        Edge & e2 = edges.back();
+        SetEdge::iterator i = map.find(e1);
+        SetEdge::iterator j = map.find(e2);
+        if (i == map.end() && j == map.end())
+        {
+            Line * line = new Line(pts);
+            line->first = &(*map.insert(e1).first);
+            line->second = &(*map.insert(e2).first);
+            line->first->line = line;
+            line->second->line = line;
+        }
+        else if (i == map.end())
+        {
+            Line * line = j->line;
+            line->add(pts);
+            const Edge * e = &(*map.insert(e1).first);
+            e->line = line;
+            if (*line->first == e2)
+            {
+                line->first = e;
+            }
+            else
+            {
+                line->second = e;
+            }
+            map.erase(j);
+        }
+        else if (j == map.end())
+        {
+            Line * line = i->line;
+            line->add(pts);
+            const Edge * e = &(*map.insert(e2).first);
+            e->line = line;
+            if (*line->first == e1)
+            {
+                line->first = e;
+            }
+            else
+            {
+                line->second = e;
+            }
+            map.erase(i);
+        }
+        else
+        {
+            Line * line1 = i->line;
+            Line * line2 = j->line;
+            if (line1 != line2)
+            {
+                line1->add(pts);
+                line1->add(line2);
+
+                const Edge * first, * second;
+
+                if (*line1->first == e1)
+                {
+                    first = line1->second;
+                }
+                else
+                {
+                    first = line1->first;
+                }
+                if (*line2->first == e2)
+                {
+                    second = line2->second;
+                }
+                else
+                {
+                    second = line2->first;
+                }
+
+                line1->first = first;
+                line1->second = second;
+                second->line = line1;
+
+                // line2 is now useless: we can delete it
+                delete line2;
+
+                map.erase(i);
+                map.erase(j);
+            }
+            else
+            {
+                line1->add(pts);
+                closedLines.push_back(line1);
+                map.erase(i);
+                map.erase(j);
+            }
+        }
+    }
+
+    clear();
+}
+
+void LevelCurve::computeLines()
+{
+    for (SetEdge::const_iterator i = map.begin(), e = map.end(); i != e; ++i)
+    {
+        if (i->line)
+        {
+            Line * line = i->line;
+            xC.push_back(zi);
+            yC.push_back(line->points.size());
+            for (std::vector<Point2D>::const_iterator j = line->points.begin(), _e = line->points.end(); j != _e; ++j)
+            {
+                xC.push_back(j->x);
+                yC.push_back(j->y);
+            }
+
+            line->second->line = 0;
+            line->first->line = 0;
+
+            delete line;
+        }
+    }
+
+    for (std::vector<Line *>::const_iterator i = closedLines.begin(), e = closedLines.end(); i != e; ++i)
+    {
+        if (*i)
+        {
+            Line * line = *i;
+            xC.push_back(zi);
+            yC.push_back(line->points.size());
+            for (std::vector<Point2D>::const_iterator j = line->points.begin(), _e = line->points.end(); j != _e; ++j)
+            {
+                xC.push_back(j->x);
+                yC.push_back(j->y);
+            }
+
+            delete line;
+        }
+    }
+
+    closedLines.clear();
+    map.clear();
+    common.clear();
+}
+
+bool LevelCurve::compute(const unsigned int size, const double * x, const double * y, const double * z, const unsigned int elementSize, const unsigned int edgeSize, const double * elems, const unsigned int levelSize, const double * levels, std::vector<double> & xC, std::vector<double> & yC)
+{
+    LevelCurve lc(xC, yC);
+    for (unsigned int i = 0; i < levelSize; ++i)
+    {
+        lc.setLevel(levels[i]);
+        for (unsigned int j = 0; j < elementSize; ++j)
+        {
+            if (elems[j + 1 * elementSize] < 1)
+            {
+                return false;
+            }
+            const unsigned int indexA = (unsigned int)elems[j + 1 * elementSize] - 1;
+            const Point3D A(indexA + 1, x[indexA], y[indexA], z[indexA]);
+            for (unsigned k = 2; k < edgeSize; ++k)
+            {
+                if (elems[j + k * elementSize] < 1)
+                {
+                    return false;
+                }
+                if (elems[j + (k + 1) * elementSize] < 1)
+                {
+                    return false;
+                }
+                const unsigned int indexB = (unsigned int)elems[j + k * elementSize] - 1;
+                const unsigned int indexC = (unsigned int)elems[j + (k + 1) * elementSize] - 1;
+                lc.intersect(A, Point3D(indexB + 1, x[indexB], y[indexB], z[indexB]), Point3D(indexC + 1, x[indexC], y[indexC], z[indexC]));
+            }
+        }
+        lc.computeLines();
+    }
+
+    return true;
+}
+}
diff --git a/scilab/modules/graphics/src/cpp/ContourOnMesh.hxx b/scilab/modules/graphics/src/cpp/ContourOnMesh.hxx
new file mode 100644 (file)
index 0000000..fc28b7f
--- /dev/null
@@ -0,0 +1,176 @@
+#ifndef __CONTOUR_ON_MESH_HXX__
+#define __CONTOUR_ON_MESH_HXX__
+
+#include <iostream>
+#include <set>
+#include <vector>
+
+namespace org_modules_graphics
+{
+
+/**
+ * \struct Point2D
+ * \brief Handle 2D geometric point
+ */
+struct Point2D
+{
+    double x;
+    double y;
+
+    Point2D() { }
+    Point2D(const double _x, const double _y) : x(_x), y(_y) { }
+
+    inline bool operator==(const Point2D & p) const
+    {
+        return x == p.x && y == p.y;
+    }
+
+    inline bool operator!=(const Point2D & p) const
+    {
+        return x != p.x || y != p.y;
+    }
+
+    friend std::ostream & operator<<(std::ostream & out, const Point2D & p)
+    {
+        out << "(" << p.x << "," << p.y << ")";
+        return out;
+    }
+};
+
+/**
+ * \struct Point3D
+ * \brief Handle 3D geometric point with an index (corresponding to the args of contour2dm)
+ */
+struct Point3D
+{
+    unsigned int index;
+    double x;
+    double y;
+    double z;
+
+    Point3D() { }
+    Point3D(const unsigned int _index, const double _x, const double _y, const double _z) : index(_index), x(_x), y(_y), z(_z) { }
+
+    friend std::ostream & operator<<(std::ostream & out, const Point3D & p)
+    {
+        out << "(" << p.index << "," << p.x << "," << p.y << "," << p.z << ")";
+        return out;
+    }
+};
+
+struct Line;
+
+/**
+ * \struct Edge
+ * \brief Represents an edge given by its two indices
+ */
+struct Edge
+{
+    unsigned int v1;
+    unsigned int v2;
+    mutable Line * line;
+
+    Edge(const unsigned int _v1, const unsigned int _v2) : v1(_v1), v2(_v2), line(0)
+    {
+        if (v2 < v1)
+        {
+            v1 = _v2;
+            v2 = _v1;
+        }
+    }
+
+    inline bool operator==(const Edge & e) const
+    {
+        return v1 == e.v1 && v2 == e.v2;
+    }
+
+    inline bool operator<(const Edge & e) const
+    {
+        return (v1 == e.v1) ? (v2 < e.v2) : (v1 < e.v1);
+    }
+
+    friend std::ostream & operator<<(std::ostream & out, const Edge & e)
+    {
+        out << "[" << e.v1 << "," << e.v2 << "]";
+        return out;
+    }
+};
+
+/**
+ * \struct Line
+ * \brief Represents a polyline starting from an edge and finishing on another one
+ */
+struct Line
+{
+    std::vector<Point2D> points;
+    const Edge * first;
+    const Edge * second;
+
+    Line(const std::vector<Point2D> & _points) : points(_points), first(0), second(0) { }
+
+    void add(const std::vector<Point2D> & pts);
+    void add(Line * line);
+
+    friend std::ostream & operator<<(std::ostream & out, const Line & l)
+    {
+        out << *l.first << ":" << *l.second << ":";
+        for (std::vector<Point2D>::const_iterator i = l.points.begin(), e = --l.points.end(); i != e; ++i)
+        {
+            out << *i << ",";
+        }
+        out << *(--l.points.end());
+
+        return out;
+    }
+};
+
+/**
+ * \class LevelCurve
+ * \brief Compute the level curves
+ */
+class LevelCurve
+{
+    typedef std::set<Edge> SetEdge;
+
+    SetEdge map;
+    SetEdge common;
+    std::vector<Point2D> pts;
+    std::vector<Edge> edges;
+    std::vector<double> & xC;
+    std::vector<double> & yC;
+    std::vector<Line *> closedLines;
+    double zi;
+
+    LevelCurve(std::vector<double> & _xC, std::vector<double> & _yC) : xC(_xC), yC(_yC), zi(0)
+    {
+        pts.reserve(2);
+        edges.reserve(2);
+    }
+
+    inline void setLevel(const double _zi)
+    {
+        zi = _zi;
+    }
+
+    inline void clear()
+    {
+        pts.clear();
+        pts.reserve(2);
+        edges.clear();
+        edges.reserve(2);
+    }
+
+    void intersect(const Point3D & A, const Point3D & B, const Point3D & C);
+    void computeLines();
+
+public:
+
+    /**
+     * \brief Computes the level curves, the arguments are almost the same as in contour2dm
+     */
+    static bool compute(const unsigned int size, const double * x, const double * y, const double * z, const unsigned int elementSize, const unsigned int edgeSize, const double * elems, const unsigned int levelSize, const double * levels, std::vector<double> & xC, std::vector<double> & yC);
+};
+
+} // namespace org_modules_graphics
+
+#endif // __CONTOUR_ON_MESH_HXX__
diff --git a/scilab/modules/graphics/tests/unit_tests/contour2dm.dia.ref b/scilab/modules/graphics/tests/unit_tests/contour2dm.dia.ref
new file mode 100644 (file)
index 0000000..48b4703
--- /dev/null
@@ -0,0 +1,76 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Calixte Denizet Charlotte Hecquet
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// 4 triangles
+m = [6 5 4; ...
+           6 2 5; ...
+           6 4 1; ...
+           5 2 3];
+nodes = [55  20; ...
+          85  5; ...
+          100 10; ...
+          75  30; ...
+          80  20; ...
+          70  15];
+z = [-1 -1 0.0001 0.0001 1 1];
+// contours
+xc_ref = [-0.5, 64.999, 58.75, -0.5, 81.25, 83.75, 92.49925, 0, 74.998, 62.5, 0, 77.5, 82.5, 99.9985, ...
+          0.5, 77.49975, 72.50025, 66.25, 0.5, 73.75, 81.25, 90.001];
+yc_ref = [2, 24.9995, 18.75, 3, 7.5, 8.75, 7.49975, 2, 29.999, 17.5, 3, 10, 12.5, 9.9995, ...
+          3, 25.0005, 22.50075, 16.25, 3, 12.5, 16.25, 14.9995];
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, [-0.5, 0, 0.5]);
+assert_checkalmostequal(xc, xc_ref);
+assert_checkalmostequal(yc, yc_ref);
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, 3);
+assert_checkalmostequal(xc, xc_ref);
+assert_checkalmostequal(yc, yc_ref);
+// 2 quadrangles
+m = [1 2 3 4; 4 3 6 5];
+nodes = [10 20; ...
+          40 20; ...
+          50 40; ...
+          5 40; ...
+          20 80; ...
+          40 80];
+z = [-1 -1 0 0 1 1];
+// contours
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, [-0.5, -0.25, 0, 0.25, 0.5]);
+xc_ref = [-0.5,45,30,7.5,-0.25,47.5,40,6.25,0,50,5,0.25,47.5,13.75,8.75,0.5,45,22.5,12.5];
+yc_ref = [3,30,30,30,3,35,35,35,2,40,40,3,50,50,50,3,60,60,60];
+assert_checkequal(xc, xc_ref);
+assert_checkequal(yc, yc_ref);
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, [-0.6 -0.2 0.2 0.6]);
+xc_ref = [-0.6,44,26,8,-0.2,48,42,6,0.2,48,12,8,0.6,44,26,14];
+yc_ref = [3,28,28,28,3,36,36,36,3,48,48,48,3,64,64,64];
+assert_checkequal(xc, xc_ref);
+assert_checkequal(yc, yc_ref);
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, 4);
+assert_checkalmostequal(xc, xc_ref);
+assert_checkalmostequal(yc, yc_ref);
+// Error messages
+// Number of arguments
+err = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "contour2dm", 5);
+assert_checkerror("[xc,yc] = contour2dm()", err);
+assert_checkerror("[xc,yc] = contour2dm(""A"", nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5], ""arg6"")", err);
+err = msprintf(_("%s: Wrong number of output argument(s): %d expected.\n"), "contour2dm", 2);
+assert_checkerror("contour2dm(""A"", nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+assert_checkerror("[xc,yc,zc] = contour2dm(""A"", nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+// Type of arguments
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 1);
+assert_checkerror("[xc,yc] = contour2dm(""A"", nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 2);
+assert_checkerror("[xc,yc] = contour2dm(nodes(:,1), ""A"", [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 3);
+assert_checkerror("[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), ""A"", z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 4);
+assert_checkerror("[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], ""A"", [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 5);
+assert_checkerror("[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, ""A"")", err);
+// Size of arguments
+err = msprintf(_("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), "contour2dm", 2, 6, 1);
+assert_checkerror("[xc,yc] = contour2dm(nodes(:,1), nodes(1,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), "contour2dm", 2, 1, 1);
+assert_checkerror("[xc, yc] = contour2dm(nodes(1,1), nodes(:,2), [m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
diff --git a/scilab/modules/graphics/tests/unit_tests/contour2dm.tst b/scilab/modules/graphics/tests/unit_tests/contour2dm.tst
new file mode 100644 (file)
index 0000000..45101ba
--- /dev/null
@@ -0,0 +1,88 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Calixte Denizet Charlotte Hecquet
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// 4 triangles
+m = [6 5 4; ...
+           6 2 5; ...
+           6 4 1; ...
+           5 2 3];
+          
+nodes = [55  20; ...
+          85  5; ...
+          100 10; ...
+          75  30; ...
+          80  20; ...
+          70  15];
+z = [-1 -1 0.0001 0.0001 1 1];
+
+// contours
+xc_ref = [-0.5, 64.999, 58.75, -0.5, 81.25, 83.75, 92.49925, 0, 74.998, 62.5, 0, 77.5, 82.5, 99.9985, ...
+          0.5, 77.49975, 72.50025, 66.25, 0.5, 73.75, 81.25, 90.001];
+yc_ref = [2, 24.9995, 18.75, 3, 7.5, 8.75, 7.49975, 2, 29.999, 17.5, 3, 10, 12.5, 9.9995, ...
+          3, 25.0005, 22.50075, 16.25, 3, 12.5, 16.25, 14.9995];
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, [-0.5, 0, 0.5]);
+assert_checkalmostequal(xc, xc_ref);
+assert_checkalmostequal(yc, yc_ref);
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, 3);
+assert_checkalmostequal(xc, xc_ref);
+assert_checkalmostequal(yc, yc_ref);
+
+// 2 quadrangles
+m = [1 2 3 4; 4 3 6 5];
+          
+nodes = [10 20; ...
+          40 20; ...
+          50 40; ...
+          5 40; ...
+          20 80; ...
+          40 80];
+z = [-1 -1 0 0 1 1];
+
+// contours
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, [-0.5, -0.25, 0, 0.25, 0.5]);
+xc_ref = [-0.5,45,30,7.5,-0.25,47.5,40,6.25,0,50,5,0.25,47.5,13.75,8.75,0.5,45,22.5,12.5];
+yc_ref = [3,30,30,30,3,35,35,35,2,40,40,3,50,50,50,3,60,60,60];
+assert_checkequal(xc, xc_ref);
+assert_checkequal(yc, yc_ref);
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, [-0.6 -0.2 0.2 0.6]);
+xc_ref = [-0.6,44,26,8,-0.2,48,42,6,0.2,48,12,8,0.6,44,26,14];
+yc_ref = [3,28,28,28,3,36,36,36,3,48,48,48,3,64,64,64];
+assert_checkequal(xc, xc_ref);
+assert_checkequal(yc, yc_ref);
+[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))', m, (1:size(m, 1))'], z, 4);
+assert_checkalmostequal(xc, xc_ref);
+assert_checkalmostequal(yc, yc_ref);
+
+
+// Error messages
+// Number of arguments
+err = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "contour2dm", 5);
+assert_checkerror("[xc,yc] = contour2dm()", err);
+assert_checkerror("[xc,yc] = contour2dm(""A"", nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5], ""arg6"")", err);
+err = msprintf(_("%s: Wrong number of output argument(s): %d expected.\n"), "contour2dm", 2);
+assert_checkerror("contour2dm(""A"", nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+assert_checkerror("[xc,yc,zc] = contour2dm(""A"", nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+
+// Type of arguments
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 1);
+assert_checkerror("[xc,yc] = contour2dm(""A"", nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 2);
+assert_checkerror("[xc,yc] = contour2dm(nodes(:,1), ""A"", [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 3);
+assert_checkerror("[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), ""A"", z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 4);
+assert_checkerror("[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], ""A"", [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong type for argument #%d: A real expected.\n"), "contour2dm", 5);
+assert_checkerror("[xc, yc] = contour2dm(nodes(:,1), nodes(:,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, ""A"")", err);
+
+
+// Size of arguments
+err = msprintf(_("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), "contour2dm", 2, 6, 1);
+assert_checkerror("[xc,yc] = contour2dm(nodes(:,1), nodes(1,2), [(1:size(m, 1))'', m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+err = msprintf(_("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), "contour2dm", 2, 1, 1);
+assert_checkerror("[xc, yc] = contour2dm(nodes(1,1), nodes(:,2), [m, (1:size(m, 1))''], z, [-0.5, -0.25, 0, 0.25, 0.5])", err);
+
index 9e5db0e..c4b1700 100644 (file)
@@ -759,6 +759,8 @@ contour2d_fr_FR_3.png=b210ca5f70b33677912b389f9712db1a
 contour2d_ja_JP_3.png=b210ca5f70b33677912b389f9712db1a
 contour2d_ja_JP_4.png=b210ca5f70b33677912b389f9712db1a
 contour2d_ru_RU_3.png=4c61560bd18df7e242044268caf62b35
+contour2dm_1.png=31a3b6c2aaa5ae5cfa0cf185d3a76caa
+contour2dm_2.png=f90a7ebef7685645fd3d5c2583b27f93
 contour_1.png=d285038265f8a3d989244534a70de17a
 contour_2.png=ac789923af59117fd684f6b073e1341a
 contour_3.png=634fbf34f0fd9907ddcf7a2faca80a9f
diff --git a/scilab/modules/helptools/images/contour2dm_1.png b/scilab/modules/helptools/images/contour2dm_1.png
new file mode 100644 (file)
index 0000000..93b12c6
Binary files /dev/null and b/scilab/modules/helptools/images/contour2dm_1.png differ
diff --git a/scilab/modules/helptools/images/contour2dm_2.png b/scilab/modules/helptools/images/contour2dm_2.png
new file mode 100644 (file)
index 0000000..95557a6
Binary files /dev/null and b/scilab/modules/helptools/images/contour2dm_2.png differ